Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where's run-server gone in compojure?

I used to be able to start a web server in compojure like this:

(run-server {:port 8080} "/*" (servlet my-app))

Does anyone know where this function has gone in the latest compojure? (0.6.2)

The docs say I'm supposed to run it from the command line and use some freaky auto-reloading thing, at which point I might as well be using python.

like image 699
John Lawrence Aspden Avatar asked Mar 20 '11 22:03

John Lawrence Aspden


1 Answers

You're looking at some seriously out-dated documentation.

For jetty, use

(use 'ring.adapter.jetty)

(defn start-web []
  (run-jetty (var my-site) {:port 8080 :join? false}))

Where my-site is your top-level handler function.

You can call that function anywhere, including from the REPL in SLIME. Recompiling/redefining my-site will work on a running server, so there's no need for auto-reloading if you're already using an interactive environment.

EDIT: compojure has been split into ring & clout, with compojure itself remaining as a small selection of higher-level abstractions on top. Most of the actual server stuff and design documentation is now in ring. See https://github.com/mmcgrana/ring/wiki

like image 147
Joost Diepenmaat Avatar answered Nov 15 '22 07:11

Joost Diepenmaat