Advertisement
Guest User

Untitled

a guest
May 25th, 2014
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (ns liberator-service.repl
  2.   (:use liberator-service.handler
  3.         ring.server.standalone
  4.         [ring.middleware file-info file]))
  5.  
  6. (defonce server (atom nil))
  7.  
  8. (defn get-handler []
  9.   ;; #'app expands to (var app) so that when we reload our code,
  10.   ;; the server is forced to re-resolve the symbol in the var
  11.   ;; rather than having its own copy. When the root binding
  12.   ;; changes, the server picks it up without having to restart.
  13.   (-> #'app
  14.     ; Makes static assets in $PROJECT_DIR/resources/public/ available.
  15.     (wrap-file "resources")
  16.     ; Content-Type, Content-Length, and Last Modified headers for files in body
  17.     (wrap-file-info)))
  18.  
  19. (defn start-server
  20.   "used for starting the server in development mode from REPL"
  21.   [& [port]]
  22.   (let [port (if port (Integer/parseInt port) 8080)]
  23.     (reset! server
  24.             (serve (get-handler)
  25.                    {:port port
  26.                     :init init
  27.                     :auto-reload? true
  28.                     :destroy destroy
  29.                     :join true}))
  30.     (println (str "You can view the site at http://localhost:" port))))
  31.  
  32. (defn stop-server []
  33.   (.stop @server)
  34.   (reset! server nil))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement