App

DELETE

defn

(Fn [App, String, (Fn [(Ref Request a), (Ref (Map String String) b)] Response)] App)

                        (DELETE app pattern handler)
                    

adds a DELETE route.

GET

defn

(Fn [App, String, (Fn [(Ref Request a), (Ref (Map String String) b)] Response)] App)

                        (GET app pattern handler)
                    

adds a GET route.

PATCH

defn

(Fn [App, String, (Fn [(Ref Request a), (Ref (Map String String) b)] Response)] App)

                        (PATCH app pattern handler)
                    

adds a PATCH route.

POST

defn

(Fn [App, String, (Fn [(Ref Request a), (Ref (Map String String) b)] Response)] App)

                        (POST app pattern handler)
                    

adds a POST route.

PUT

defn

(Fn [App, String, (Fn [(Ref Request a), (Ref (Map String String) b)] Response)] App)

                        (PUT app pattern handler)
                    

adds a PUT route.

copy

instantiate

(Fn [(Ref App a)] App)

copies a App.

create

defn

(Fn [] App)

                        (create)
                    

creates an empty App with no routes and a default error handler.

delete

instantiate

(Fn [App] ())

deletes a App. Should usually not be called manually.

error-handler

instantiate

(Fn [(Ref App a)] (Ref (Fn [(Ref Request b), Int, String] Response) a))

gets the error-handler property of a App.

init

instantiate

(Fn [(Array Route), (Fn [(Ref Request a), Int, String] Response)] App)

creates a App.

prn

instantiate

(Fn [(Ref App a)] String)

converts a App to a string.

route

defn

(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.

routes

instantiate

(Fn [(Ref App a)] (Ref (Array Route) a))

gets the routes property of a App.

running

def

Bool

serve

defn

(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

defn

(Fn [App, (Fn [(Ref Request a), Int, String] Response)] App)

                        (set-error app handler)
                    

sets a custom error handler.

set-error-handler

instantiate

(Fn [App, (Fn [(Ref Request a), Int, String] Response)] App)

sets the error-handler property of a App.

set-error-handler!

instantiate

(Fn [(Ref App a), (Fn [(Ref Request b), Int, String] Response)] ())

sets the error-handler property of a App in place.

set-routes

instantiate

(Fn [App, (Array Route)] App)

sets the routes property of a App.

set-routes!

instantiate

(Fn [(Ref App a), (Array Route)] ())

sets the routes property of a App in place.

static-dir

defn

(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.

str

instantiate

(Fn [(Ref App a)] String)

converts a App to a string.

update-error-handler

instantiate

(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

instantiate

(Fn [App, (Ref (Fn [(Array Route)] (Array Route) a) b)] App)

updates the routes property of a App using a function f.