Created
April 7, 2015 18:12
-
-
Save emidln/add4a2d31fb84977f911 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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