k7d / hop

Minimalistic non-blocking web server for Clojure

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hop

Hop is a minimalistic asynchronous web server for Clojure designed to be used in concert with core.async.

Hop's request and response formats are compatible with Ring. Hop's request handlers however must return core.async channel and supply the response via the channel.

Under the hood, Hop is built on top of Netty framework.

Example

(ns hello-world.core
  (:require [clojure.core.async :refer [go <! timeout]]
            [hop.server :as server]))

(defn handler [req]
  (go
    ; simulate wait (in real world this would be waiting for some I/O to happen)
    (<! (timeout 1000))
    {:status 200
     :headers {"Content-Type" "text/plain"}
     :body "Hello World"}))

(defn -main [& args]
  (server/start-server handler))

About

Minimalistic non-blocking web server for Clojure


Languages

Language:Clojure 100.0%