Fork me on GitHub

The convention used by Compojure is that all (most?) of its helper functions and macros like GET, POST, resources, files, etc. are ultimately Ring handlers, with the small difference that they have the option of returning nil as a way to say "look at the next handler instead"


(which is what routes relies on)


That's how you can go (routes (GET ...) (GET ...)) because GET will return nil if the request doesn't match


Anyway, bottom line is resources returns a ring handler


which means you can apply middleware to it


So something like this should work out for your case here:

  (fn [req] (let [resp ((route/resources "/") req)]
              (update resp :headers merge {"Cache" ...})))


Thank you @gaverhae! Wish the API doc mention this 🙂


Note that if resources is not the last handler in the compojure chain, you'll probably want to turn that let into a when-let so as not to break the convention.


Hello. I am trying to create a new default Reagent app. Then I would like to know how to produce a static HTML page and a minified JS script that I could host in Tomcat. It sounds easy, but this has proven very difficult for me. Could someone walk me through the build process for deploying to production? Thanks.


Saving the HTML page puts a lot of extra figwheel stuff in that I don't want. There needs to be a better way to produce static HTML.


And it seems that my on-change events aren't getting in for some reason. I'm pretty confused. That's why I would just like to work with someone, going from a default Reagent app to deploying it in Tomcat. Thanks.


Hi, I would like to use ssh-copy-id command from Clojure. If I run this command (sh "bash" "-c" "ssh-copy-id -i /Users/sb/.ssh/ [email protected]") then I need send a password too. With echo password | command don’t want to work. Any idea how to solve in Clojure, send a password in the session?


maybe use ssh-agent along with it?


in your bash shell, I mean


@manutter51 i check it


@its.ramzi Have you taken a look at tenzing? It's a template to do static clojurescript apps, so should be a fairly good fit given your description.


When trying to use uberwar, I run into this error: Could not locate ring/middleware/cors__init.class or ring/middleware/cors.clj on classpath.


Any idea how to resolve it?


@its.ramzi Hard to say without more detail -- how are you specifying middleware dependencies in your project? Are you using lein, boot, or the new clj stuff? How are you creating your JAR/WAR file? Have you tested running the app in a REPL locally? (highly recommended -- Clojure can specifically avoid the compile-deploy-test cycle of other languages by letting you compile and run code directly and interactively in the REPL)


(why are you creating a WAR file anyway? that's not a common path for web app deployment in Clojure -- there are definitely easier, more idiomatic ways)


@seancorfield I was using lein. Lein uberwar. The Reagent app comes out of the box as deployable with figwheel; I just don't know how to do a production deployment. I want to replace the GUI using Clojurescript, but keep the Java/Hibernate/Postgres backend that is in place. So I wanted to create a .war file that is deployable in Tomcat or Wildfly.