-
Notifications
You must be signed in to change notification settings - Fork 150
Remove macro-peeling to get the swagger-docs out #178
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
Labels
Milestone
Comments
WIP in https://github.com/metosin/compojure-api/tree/runtime-route-resolution Bye-bye (facts "nested routes"
(let [middleware (fn [handler] (fn [request] (handler request)))
more-routes (fn [version]
(routes*
(GET* "/more" []
(ok {:message version}))))
routes (context* "/api/:version" []
:path-params [version :- String]
(GET* "/ping" []
(ok {:message (str "pong - " version)}))
(middlewares* [middleware]
(GET* "/hello" []
:return {:message String}
:summary "cool ping"
:query-params [name :- String]
(ok {:message (str "Hello, " name)}))
(more-routes version)))]
(fact "routes can be extracted at runtime"
(let [routes (r/get-routes routes)]
routes => [["/api/:version/ping" :get {:parameters {:path {:version String, s/Keyword s/Any}}}]
["/api/:version/hello" :get {:parameters {:query {:name String, s/Keyword s/Any}
:path {:version String, s/Keyword s/Any}}
:responses {200 {:description "", :schema {:message String}}}
:summary "cool ping"}]
["/api/:version/more" :get {:parameters {:path {:version String, s/Keyword s/Any}}}]])))) |
In one of the big c-api projects (with 100+ routes), the compile-time is no 750x faster with the new route collector. |
merged to master. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Biggest source of Evil in Compojure-api is the custom macro-peeler, to resolve the swagger-docs.
Why it's bad:
defroutes*
=> can't create subroutes via functions (passing system via closure)A better option:
GET*
etc) return Records/Types, from where we extract the swagger-docs at runtime via a Ring-swagger protocol.did a simple spike, looks promising.
The text was updated successfully, but these errors were encountered: