Skip to content

Compile to non-linear routing strategies #467

@frenchy64

Description

@frenchy64

These will probably have to be different than reitit's since route conflicts are idiomatic. We'll probably want more types of routing between trie and linear.

I think routing based on HTTP verb is a good start;

e.g.,

(context "/foo" []
  (GET "/bar" [] (ok 1))
  (POST "/bar" [] (ok 1))
  (PUT "/bar" [] (ok 1))
  (PATCH "/bar" [] (ok 1)))
=>
(context "/foo" req
  (case (get-http-verb req)
    :GET (GET "/bar" [] (ok 1))
    :POST (POST "/bar" [] (ok 1))
    :PUT (PUT "/bar" [] (ok 1))
    :PATCH (PATCH "/bar" [] (ok 1))))

This could probably be achieved at runtime by reifying some of the structure of a route macro at runtime.

Maybe a static context can communicate to its endpoints to return a data representation of themselves instead of expanding to compojure and the static context can compile a more efficient router.

This could be accomplished more dynamically by having context bind a dynamic variable and expanding endpoints to code that checks for this variable to decide whether to return a data representation or a compojure route.

This has the advantage over static transformation under a context of working even if the endpoint is not directly under the context (say, separated by a function call).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions