Skip to content

Redesign Router API #184

Description

@acobster

Problems with the current API

  1. It doesn't compose
    a. Reitit middleware and coercion don't work
    b. Default handlers are hard to use
    c. Doesn't work with macro-based routing (not sure if we can solve this one?)
  2. The API sucks
    • route-spec, route-params, and route-dispatcher can be combined into one fn that just returns all the data

Solutions

(2) is easy; just update API and call sites.

(1) is harder. Maybe we can dynamically create a handler fn for each dispatcher. This is effectively decreasing the scope of Bread itself.

This vastly simplifies the ::route lifecycle phase, since we know at dispatch time which route we picked. All we do is inject the data already on hand from the matched route. The Reitit Router implementation, for example, could just grab ::r/match (injected by reitit.ring) from the request itself.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions