web
A web framework for Carp with routing, JSON integration, WebSocket support, and concurrent connection handling.
Define handlers as (Fn [&Request &(Map String String)] Response) functions,
register them as routes on an App, and start serving with
App.serve.
HTTP Example
(load "git@github.com:carpentry-org/web@0.5.0")
(defn hello [req params]
(Response.text @"Hello, world!"))
(defserver "0.0.0.0" 8080
(GET "/" hello))
WebSocket Example
(defn echo [event params ws]
(match-ref event
(WSEvent.Connect) (WebSocket.send ws @"connected")
(WSEvent.Message msg) (WebSocket.send ws (fmt "echo: %s" msg))
(WSEvent.Close) ()))
(defserver "0.0.0.0" 8080
(WS "/ws/echo" echo))