In your project, require:
(require '[piotr-yuxuan.ephemeral-server :as ephemeral-server])
You now may open an ephemeral server that will live a short but beautiful life ✨.
(let [port (atom nil]
(with-open [_ (ephemeral-server/open port ["/ping" {:get (constantly {:body "expected"})}])]
;; Now @port is set to its actual value.
(->> (http/get (format "http://localhost:%s/ping" @port))
deref
:body
slurp)))
In your project, require:
``` clojure
(require '[piotr-yuxuan.ephemeral-server :as ephemeral-server])
```
You now may open an ephemeral server that will live a short but
beautiful life ✨.
``` clojure
(let [port (atom nil]
(with-open [_ (ephemeral-server/open port ["/ping" {:get (constantly {:body "expected"})}])]
;; Now @port is set to its actual value.
(->> (http/get (format "http://localhost:%s/ping" @port))
deref
:body
slurp)))
```(open port route-data)(open port route-data {:keys [route handler]})Takes two arguments, an empty atom port and reitit definition of
ring routes. Return a Closeable server with given routes on
first available port and set the atom port on the value being
used.
Takes two arguments, an empty atom `port` and reitit definition of ring `routes`. Return a `Closeable` server with given `routes` on first available port and set the atom `port` on the value being used.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |