Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile to non-linear routing strategies #467

Open
frenchy64 opened this issue Apr 29, 2024 · 0 comments
Open

Compile to non-linear routing strategies #467

frenchy64 opened this issue Apr 29, 2024 · 0 comments

Comments

@frenchy64
Copy link
Collaborator

frenchy64 commented Apr 29, 2024

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant