Coder Social home page Coder Social logo

component-webserver's Introduction

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.

component-webserver's People

Contributors

phenomdevel avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.