Open mitchelkuijpers opened 5 years ago
Btw we currently fix the routing by doing this:
(app (update request :uri #(str/replace-first % (:servlet-context-path request "") "")))
Hi, I had the same problem with Tomcat and with the help of @ikitommi i made this :
(defn handler [request]
{:status 200, :body "ok"})
(defn wrap-servlet-adapt-uri [handler]
(fn [request]
; remove from the :uri the :servlet-content-path to adapt to reitit routes
(handler (update request :uri #(cstr/replace-first % (:servlet-context-path request "") "")))))
(def router
(ring/router
[["/" {:get handler}]
["/ping" {:get handler}]]))
(def app (ring/ring-handler
router
nil
; apply middleware before routing
{:middleware [wrap-servlet-adapt-uri]}))
And it now work. Thanks
We are currently using reitit with ring-servlet. And our servlet is mounted under a context which we get in the ring request map it looks like this:
Now we would expect the http reitit router strips the "/servlets" part while routing. And when we do reverse based routing we would expect reitit to add the /servlets part. Maybe we can add a
context
option to reitit. One thing to note is that the option should probably not be static because you can sometimes access servlets from multiple context paths.