Closed johanhaleby closed 9 years ago
The reason I want to do this is because I'd like to combine one handler that is protected by basic auth and another handler that is not protected by basic auth in the same jetty-server instance
@johanhaleby It's pretty straightforward. Here's an incomplete, but hopefully sufficient example:
(defn endpoint-1 [_]
(-> (GET ...)
(wrap-stuff)
(routes)))
(defn endpoint-2 [_]
(-> (GET ...)
(wrap-other-stuff)
(routes)))
(defn new-system [config]
(-> (c/system-map
...
:endpoint-1 (endpoint-component endpoint-1)
:endpoint-2 (endpoint-component endpoint-2))
(c/system-using
{:http [:app]
:app [:endpoint-1 :endpoint-2]
:endpoint-1 []
:endpoint-2 []})))
@kendagriff has it right. You can read more about the handler component on the wiki. The handler component is designed to combine the handlers from multiple endpoints into one.
Thanks a lot, exactly what I need! Sorry I didn't see the wiki, the new github layout confuse me. I'm going to close this.
I have two handler-components, a & b, and I like to expose both on the same jetty-server (something similar to how you combine two or more handlers in vanilla compojure using
(routes some-handler some-other-handler)
). Is this possible?