Skip to content

Instantly share code, notes, and snippets.

@emidln
Created April 7, 2015 18:12
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 emidln/add4a2d31fb84977f911 to your computer and use it in GitHub Desktop.
Save emidln/add4a2d31fb84977f911 to your computer and use it in GitHub Desktop.
(s/defrecord HttpKitWebServer
[server :- s/Fn
ip :- s/Str
port :- s/Int
app :- RingHandler]
component/Lifecycle
(start [this]
(when server (server))
(let [nserver (httpkit/run-server (:app app)
{:port port
:ip ip
:max-body (pre (* 1024 1024 220))})]
(assoc this :server nserver)))
(stop [this]
(when server
;; do stuff before killing it
(server))
(dissoc this :server)))
(defnk new-httpkit-web-server
"Creates an HTTP-Kit component with an injectable ring handler"
[ip :- s/Str
port :- s/Int]
(map->HttpKitWebServer {:ip ip :port port}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment