Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
7 changes: 6 additions & 1 deletion src/pandeiro/boot_http.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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."
Expand All @@ -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]
Expand All @@ -57,15 +60,17 @@
(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}))
(def nrepl-server
(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!))
Expand Down
4 changes: 2 additions & 2 deletions src/pandeiro/boot_http/impl.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down