I’m trying to understand how the :context key for a ring request is handled by compojure. I can see that it’s read here https://github.com/weavejester/compojure/blob/1f921964801ef4ba45b7e694bc9c6a27394c1300/src/compojure/core.clj#L258 and passed on here https://github.com/weavejester/compojure/blob/1f921964801ef4ba45b7e694bc9c6a27394c1300/src/compojure/core.clj#L264, but I can’t really see where its value is used. The reason why I’m asking is that I have set the :context myself for another purpose, which completely broke my app. Now I’m trying to figure out where the breaking happens.
The context macro in Compojure, and the set-context function in Ring, split the :uri of a request map into a :context and :path-info parts.
So for example:
(compojure/context "/foo"
(compojure/GET "/bar" []
"This will match /foo/bar. The context is /foo, and the path-info is /bar"))Thanks! I was able to figure out that setting :context myself broke metosin's ring-swagger library. But I managed to solve it. 🙂
Also, if I read the source right, the context let-binding is never used? https://github.com/weavejester/compojure/blob/1f921964801ef4ba45b7e694bc9c6a27394c1300/src/compojure/core.clj#L258
Yeah, that looks like a line that can be removed.