App
DELETE
(Fn [App, String, (Fn [(Ref Request a), (Ref (Map String String) b)] Response)] App)
(DELETE app pattern handler)
adds a DELETE route.
GET
(Fn [App, String, (Fn [(Ref Request a), (Ref (Map String String) b)] Response)] App)
(GET app pattern handler)
adds a GET route.
PATCH
(Fn [App, String, (Fn [(Ref Request a), (Ref (Map String String) b)] Response)] App)
(PATCH app pattern handler)
adds a PATCH route.
POST
(Fn [App, String, (Fn [(Ref Request a), (Ref (Map String String) b)] Response)] App)
(POST app pattern handler)
adds a POST route.
PUT
(Fn [App, String, (Fn [(Ref Request a), (Ref (Map String String) b)] Response)] App)
(PUT app pattern handler)
adds a PUT route.
error-handler
(Fn [(Ref App a)] (Ref (Fn [(Ref Request b), Int, String] Response) a))
gets the error-handler property of a App.
init
(Fn [(Array Route), (Fn [(Ref Request a), Int, String] Response)] App)
creates a App.
route
(Fn [App, String, String, (Fn [(Ref Request a), (Ref (Map String String) b)] Response)] App)
(route app method pattern handler)
adds a route to the app.
serve
(Fn [(Ref App a), (Ref (Array (Fn [(Ref Request b), (Ref (Map String String) c)] (Maybe Response) d)) a), (Ref (Array (Fn [(Ref Request e), (Ref (Map String String) f), Response] Response g)) a), (Ref String h), Int] ())
(serve app before-hooks after-hooks host port)
starts the web server on host:port.
Uses kqueue/epoll for concurrent connection handling with HTTP keep-alive. Sockets are non-blocking, reads accumulate into a per-connection buffer, and writes drain across writable events.
The loop is single-threaded, so peak throughput is bounded by one core. For multi-core scaling, run several copies behind a TCP load balancer.
set-error
(Fn [App, (Fn [(Ref Request a), Int, String] Response)] App)
(set-error app handler)
sets a custom error handler.
set-error-handler
(Fn [App, (Fn [(Ref Request a), Int, String] Response)] App)
sets the error-handler property of a App.
set-error-handler!
(Fn [(Ref App a), (Fn [(Ref Request b), Int, String] Response)] ())
sets the error-handler property of a App in place.
set-routes!
(Fn [(Ref App a), (Array Route)] ())
sets the routes property of a App in place.
static-dir
(Fn [App, String] App)
(static-dir app dir)
registers a wildcard GET route that serves files from
dir on disk via sendfile. Register after API routes so it acts as a
fallback.
update-error-handler
(Fn [App, (Ref (Fn [(Fn [(Ref Request a), Int, String] Response)] (Fn [(Ref Request a), Int, String] Response) b) c)] App)
updates the error-handler property of a App using a function f.
update-routes
(Fn [App, (Ref (Fn [(Array Route)] (Array Route) a) b)] App)
updates the routes property of a App using a function f.