Search code examples
intellij-ideaclojureringcompojure

How to use compojure from Intellij


I've spent more time that I want to admit trying to compile and run a compojure app from intellij. From the command line I use lein ring server-headless. If I run from inside intellij the REPL begins and I can't call or start the server from inside the REPL. How can I compile and run a server from inside the REPL?


Solution

  • You want to run the server from inside the repl?

    Add [ring/ring-jetty-adapter "1.3.1"] as a dependency

    In the REPL:

    (require 'ring.adapter.jetty)

    (require 'quals.core.handler) ; require YOUR ns containing the handler

    (ring.adapter.jetty/run-jetty quals.core.handler/app {:port 3004})

    You can see all the parameters you can pass here: http://mmcgrana.github.io/ring/ring.adapter.jetty.html

    There you have it, the server is running in your repl. If you were looking for more, you can always look at weavejester/lein-ring's source code.

    Have fun Clojuring around :)