This library provides an easy to use com.stuartsierra/component
component to start up a http-kit
webserver which
can be provided with a handler. The handler then will handle all incoming requests.
To install, add the following to your project :dependencies
:
[de.phenomdevel/component-webserver "1.0.0"]
The code below shows an lightweight example of how you could use this component within your
com.stuartsierra/component
system.
(require '[de.phenomdevel.components.webserver :as webserver])
(require '[com.stuartsierra.component :as c])
;; Could also come from a file or something
(def ^:private config
{:server
{:port 1212}})
;; This might also be a compojure handler
(defn- app-handler
[request]
{:status 200
:body "Hello World"})
(def !system
(atom
(c/system-map
:server
(webserver/new-webserver (merge (:server config)
{:handler app-handler})))))
(swap! !system c/start)
;; This will start your system with the webserver
Copyright © 2020 Kevin Kaiser
Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.
Can you improve this documentation? These fine people already did:
Kevin Kaiser & KevinEdit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close