diff --git a/README.md b/README.md index f88dbac..2b25cdd 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ that can serve resources, directories or a typical ring handler. [](dependency) ```clojure -[pandeiro/boot-http "0.7.3"] ;; latest release +[pandeiro/boot-http "0.7.4-SNAPSHOT"] ;; latest release ``` [](/dependency) diff --git a/src/pandeiro/boot_http.clj b/src/pandeiro/boot_http.clj index b269b93..fdb80fa 100644 --- a/src/pandeiro/boot_http.clj +++ b/src/pandeiro/boot_http.clj @@ -7,6 +7,7 @@ [boot.task.built-in :as task])) (def default-port 3000) +(def default-host "localhost") (def serve-deps '[[ring/ring-core "1.4.0"] @@ -34,6 +35,7 @@ c cleanup SYM sym "A function to run after the server stops." r resource-root ROOT str "The root prefix when serving resources from classpath" p port PORT int "The port to listen on. (Default: 3000)" + I ip-or-host HOST str "The ip or host to listen on." k httpkit bool "Use Http-kit server instead of Jetty" s silent bool "Silent-mode (don't output anything)" R reload bool "Reload modified namespaces on each request." @@ -47,6 +49,7 @@ (seq nrepl) (conj nrepl-dep)) worker (pod/make-pod (update-in (core/get-env) [:dependencies] into deps)) + host (or ip-or-host default-host) start (delay (pod/with-eval-in worker (require '[pandeiro.boot-http.impl :as http] @@ -57,6 +60,7 @@ (def server (http/server {:dir ~dir, :port ~port, :handler '~handler, + :host ~host :reload '~reload, :env-dirs ~(vec (:directories pod/env)), :httpkit ~httpkit, :not-found '~not-found, :resource-root ~resource-root})) @@ -64,8 +68,9 @@ (when ~nrepl (http/nrepl-server {:nrepl ~nrepl}))) (when-not ~silent - (boot/info "Started %s on http://localhost:%d\n" + (boot/info "Started %s on http://%s:%d\n" (:human-name server) + ~host (:local-port server)))))] (when (and silent (not httpkit)) (silence-jetty!)) diff --git a/src/pandeiro/boot_http/impl.clj b/src/pandeiro/boot_http/impl.clj index 503ebaf..799b472 100644 --- a/src/pandeiro/boot_http/impl.clj +++ b/src/pandeiro/boot_http/impl.clj @@ -119,12 +119,12 @@ :local-port (-> server .getConnectors first .getLocalPort) :stop-server #(.stop server)})) -(defn server [{:keys [port httpkit] :as opts}] +(defn server [{:keys [host port httpkit] :as opts}] ((if httpkit start-httpkit start-jetty) (-> (ring-handler opts) wrap-content-type wrap-not-modified) - {:port port :join? false})) + {:ip host :host host :port port :join? false})) ;; ;; nREPL