Skip to content

Instantly share code, notes, and snippets.

@Jannis
Created February 19, 2016 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jannis/ecd80a53ac8e2f416dd1 to your computer and use it in GitHub Desktop.
Save Jannis/ecd80a53ac8e2f416dd1 to your computer and use it in GitHub Desktop.
(ns server.services.web-server
(:require [aleph.http :as http]
[bidi.ring :as br]
[clojure.java.io :as io]
[clojure.tools.logging :refer [info]]
[mount.core :refer [defstate]]
[yada.yada :refer [yada]]
[yada.resources.classpath-resource :refer [new-classpath-resource]]
[server.config :refer [config]]))
(def routes
["/" (yada (new-classpath-resource "public/"))])
(defstate web-server
:start (do
(info "Starting web server")
(let [options (get-in config [:web-server :options])]
(http/start-server (br/make-handler routes) options)))
:stop (do
(info "Stopping web server")
(.close web-server)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment