Skip to content
Hoplite
Theme

Begin typing to search this site.

Requests and responses

The default :request adapter gives a handler a lazy map-compatible request. Lookup, get, find, count, iteration, assoc, and dissoc use Hara’s extension collection protocols. Nginx request memory is borrowed only for the handler lifetime; retaining the request and reading it after completion raises hoplite/request-closed.

The request keys are :method, :uri, :path, :query-string, :remote-address, and :headers. Headers are themselves lazy and map-like. Use :request+hta when the handler or an adapter boundary requires an owned, portable HTA value.

A handler may return a response map directly:

{:status 200
:headers {"content-type" "application/json"}
:body "{\"ready\":true}"}

hoplite.core/response can tag an existing definition or construct a status/body response:

(h/response {:status 204})
(h/response 404 "Not found\n")

Public response returns a logical value; Nginx remains responsible for emitting the HTTP response.

Experimental

hoplite.core/stream marks a coroutine or producer as a backpressured response stream:

(h/stream source)

The constructor is visible today, but the streaming host contract is pre-release and may change before the first stable package.