-
Notifications
You must be signed in to change notification settings - Fork 147
Description
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).