I'm using moustache and ring in a project. Also, I'm using lein-ring
so I can easily deploy as a war file. Java servlet containers allow
you to deploy a web app to different context paths. Say during
development, on my local machine, I'd like the context path to be "/"
but when deployed to production I'd like it to be "/myapp".
Is there a way to accomplish this with the libraries listed above?
ATM, my moustache routes do not match unless I'm using the root path.
Thanks,
Allen
lein-ring adds two additional keys when compiled as a war:
:path-info - equivalent to getPathInfo
:context - equivalent to getContextPath
This stems from a discussion we had on the Ring group. It was
suggested that these keys be added to the Ring SPEC, but Mark wanted
to see how they worked in practise first.
These keys are supported by the stuff I've written (Compojure,
lein-ring, etc.), but I don't believe Moustache supports them.
However, you could cobble together some middleware that rewrites the
:uri key with the :path-info key:
(defn wrap-context-uri [handler]
(fn [request]
(handler (assoc request uri (request :path-info)))))
- James