Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Clojars Project cljdoc badge License: MIT

component-webserver

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.

Installation

To install, add the following to your project :dependencies:

[de.phenomdevel/component-webserver "1.0.1"]

Usage

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- handler-factory
  [context] ;; Holds all dependencies of `webserver` e.g. if you provide a db-pool component
  (fn [request]
   {:status 200
    :body "Hello World"}))

(def !system
  (atom
   (c/system-map
     :server
     (webserver/new-webserver (assoc (:server config) :handler-factory handler-factory}))))

(swap! !system c/start)
;; This will start your system with the webserver

License

Copyright © 2020 Kevin Kaiser

Distributed under the MIT License.

About

Provides a webserver component using `org.httpkit` to use within a `com.stuartsierra/component` system.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages