Skip to content
Jennifer Programming Language

web API reference

An ergonomic HTTP framework over the httpd server engine. Register routes against handler func values, then web.run owns the accept loop, matches each request, and dispatches to the handler. A handler is a func value - func name(ctx as web.Context) { ... }, passed by its bare name (web.get($app, "/x", showUser)) - and it is called through its home interpreter, so an entry-program handler runs in the entry program's context across the module boundary. Routing supports :param segments, a middleware chain, and a custom not-found handler. Response and request helpers hang off the web.Context so a handler rarely reaches for httpd directly. Needs the default jennifer binary (the httpd engine is net-backed; the constrained jennifer-tiny has no network stack).

CONCURRENCY: the serve loop handles requests concurrently - it accepts a request, hands it to its own spawned worker, and immediately accepts the next, so a handler that blocks (a sql query, an outbound http call, a slow filesystem read) no longer stalls every other request. In-flight concurrency is bounded by the httpd engine's accept rate. Dispatch calls each handler func value, which runs in its home (entry-program) context, and that cross-boundary call path is race-safe: each worker carries its own call-depth counter, and reads of shared program state (globals, constants, maps) are safe. The one thing that is not safe by construction is a handler writing a shared top-level variable of the entry program: those workers run against the same host globals (unlike a top-level spawn, which snapshots), so two handlers mutating one global race. Keep per-request mutable state in the request/response or a synchronized store (the session module), not in a top-level def a handler assigns.

Import with import "web.j" as web;. See the web guide for prose and examples.

Contents

NameWhat it is
allocBudgetSet a per-request allocation budget, returning a new App.
basicAuthParse the request's HTTP Basic credentials.
bearerTokenReturn the request's bearer token (the <token> in Authorization: Bearer <token>), or "" when absent.
beforeRegister a middleware handler, run before each route handler.
bodyReturn the raw request body as bytes (binary-safe).
bodyJsonDecode the request body as JSON.
cookieReturn the value of the request cookie named name, or "" if absent.
corsSet the CORS policy for the whole app, returning a new App.
csrfCheckValidate the request's CSRF token: the submitted token (the X-CSRF-Token header, else the csrf form fie...
csrfTokenMint a CSRF token, set it in the __Host-csrf cookie (csrf under JENNIFER_WEB_INSECURE_COOKIES=1), and r...
deleteRegister a DELETE handler for a pattern, returning a new App.
etagSet an ETag and honour a conditional GET.
formParse an application/x-www-form-urlencoded request body into a map of decoded field names to values.
formValueReturn one form field's value, or "" when absent.
getRegister a GET handler for a pattern, returning a new App.
headerReturn a request header value.
htmlAnswer with a text/html body.
isOpenWhether the request is still waiting for its answer.
joinRouteConcatenate a mount prefix and a route pattern into one clean pattern: drops empty segments (so stray or do...
methodReturn the request's HTTP method.
mountMount a sub-router's routes under a path prefix, returning a new App.
multipartFormParse a multipart/form-data request body (a file-upload form) into its parts, using the request's Content...
newReturn an empty App with no routes or middleware.
notFoundSet a custom handler for unmatched requests (default: a plain 404).
onErrorRegister an error handler, returning a new App.
onServerErrorRegister an error handler for server faults only, returning a new App: as web.onError, but the handler is...
paramReturn a captured path parameter, or "" if the route had none by that name.
patchRegister a PATCH handler for a pattern, returning a new App.
pathReturn the request's URL path.
postRegister a POST handler for a pattern, returning a new App.
putRegister a PUT handler for a pattern, returning a new App.
queryReturn a query-string parameter value.
rawQueryReturn the whole query string as the client sent it, without the "?": still percent-encoded, with every key...
redirectRedirect to location with the given status (301 / 302 / 303 / 307 / 308).
remoteAddrReturn the client's network address (host:port).
remoteHostReturn the client's host without the port: 192.0.2.7 for 192.0.2.7:53412, 2001:db8::1 for...
renewSessionRotate the session id: mint a fresh UUID, set it as the session cookie, and return the new id.
respondAnswer the request with a status code and body.
routeRegister a handler for a method + pattern, returning a new App.
runListen on addr and serve forever, dispatching each request to its matched handler.
sendGzipAnswer with a body, gzip-compressed when the client accepts it.
sendJsonAnswer with an application/json body encoded from a json.Value.
serveDirServe static files from a directory root (path-safe; 404 for a missing file, a dotfile other than...
serveFileAnswer with a file from disk.
serveOnServe on an already-listening httpd.Server, dispatching each request to its matched handler.
sessionIdReturn the request's session id, minting a new one on first use.
setCookieSet a response cookie with the given attributes (a Set-Cookie header).
setHeaderSet a response header.
textAnswer with a text/plain body.
Appstruct: The value-semantic router state: the routes, the middleware chain (handler func values run before each rout...
BasicCredentialsstruct: Parsed HTTP Basic credentials from the request.
Contextstruct: What a handler receives: the underlying request handle plus the path parameters captured from the matched r...
CookieOptionsstruct: Attributes for a Set-Cookie header.
CorsOptionsstruct: A cross-origin (CORS) policy.
Routestruct: One registered (method, pattern, handler) triple.
WebErrorstruct: The error web throws, for every error of kind "web": a request body that cannot be read (status 400) or...

Functions

allocBudget

jennifer
web.allocBudget(app as App, maxBytes as int)

Set a per-request allocation budget, returning a new App. Each request's worker task calls task.setAllocBudget(bytes) before routing, so the middleware, the handler and every task they spawn count what they allocate against it. A request that passes it raises a catchable "limit" in its handler; one that escapes is answered 500 and written to stderr (the server refusing to spend more on the request, not a client sending too much, even when a body parser hit it), and the other requests are unaffected. The count is cumulative (bytes allocated, not live), see task.setAllocBudget. math.MAX_INT removes the budget.

app
the router to extend
maxBytes
the budget per request in bytes, > 0 (math.MAX_INT for none)
Returns App
a new App with the budget set
Throws WebError
kind "web", status 500, for 0 or a negative maxBytes

basicAuth

jennifer
web.basicAuth(ctx as Context)

Parse the request's HTTP Basic credentials. Checking them (against a user store) and sending a 401 challenge are the app's - web only decodes the header.

ctx
the request context
Returns BasicCredentials
the decoded credentials (present false if absent / invalid)

bearerToken

jennifer
web.bearerToken(ctx as Context)

Return the request's bearer token (the <token> in Authorization: Bearer <token>), or "" when absent. Validate it yourself (an opaque lookup, or the jwt module's jwt.verify).

ctx
the request context
Returns string
the bearer token, or "" when absent

before

jennifer
web.before(app as App, handler as func)

Register a middleware handler, run before each route handler. A middleware is func name(ctx as web.Context) { ...; return true; }: return true to continue to the route handler, or respond and return false to halt.

app
the router to extend
handler
the middleware func value
Returns App
a new App with the middleware appended to the chain

body

jennifer
web.body(ctx as Context)

Return the raw request body as bytes (binary-safe). Use web.form / web.bodyJson for the common structured bodies, or encoding.decode("utf-8", ...) for text.

ctx
the request context
Returns bytes
the request body

bodyJson

jennifer
web.bodyJson(ctx as Context)

Decode the request body as JSON. A body that is not UTF-8 or not JSON throws a WebError with status 400, which the safety net answers as such unless the handler catches it.

ctx
the request context
Returns json.Value
the decoded request body
Throws WebError
kind "web", status 400, for a malformed body; kind "limit", status 413, past the decoder's caps
jennifer
web.cookie(ctx as Context, name as string)

Return the value of the request cookie named name, or "" if absent.

ctx
the request context
name
the cookie name
Returns string
the cookie value, or "" when absent

cors

jennifer
web.cors(app as App, opts as CorsOptions)

Set the CORS policy for the whole app, returning a new App. When set (a non-empty opts.allowOrigin), the serve loop adds the Access-Control-* headers to every response and answers a preflight OPTIONS request with a 204 before routing.

app
the router to configure
opts
the CORS policy
Returns App
a new App with the policy set

csrfCheck

jennifer
web.csrfCheck(ctx as Context, secret as string)

Validate the request's CSRF token: the submitted token (the X-CSRF-Token header, else the csrf form field) must equal the CSRF cookie and its signature must verify. Guard unsafe methods (POST / PUT / PATCH / DELETE) with a web.before middleware that calls this and rejects on false.

ctx
the request context
secret
the app's CSRF secret
Returns bool
true when the request carries a valid token
Throws Error
kind "web" when secret is empty and the request carries a token matching its CSRF cookie (the signature check needs the secret); a request without one is refused (false) before that

csrfToken

jennifer
web.csrfToken(ctx as Context, secret as string)

Mint a CSRF token, set it in the __Host-csrf cookie (csrf under JENNIFER_WEB_INSECURE_COOKIES=1), and return it for embedding in a form (a hidden csrf field) or handing to the client for an X-CSRF-Token header. Call from the GET handler that renders the form.

Idempotent per request: the token (and the cookie) are minted on the first call and memoized for the rest of the request, so calling it once per form is safe. A page that renders many forms in a loop, or page chrome (a header sign-out button) that mints its own token after the body, all get the same token bound to the one CSRF cookie - every form on the page validates. (The cookie carries a single value; a second, different token would replace it and invalidate every form already rendered.)

ctx
the request context
secret
the app's CSRF secret (stable per deployment)
Returns string
the token to embed in the form / send as a header
Throws Error
kind "web" when secret is empty (an unset environment variable, typically), since anyone could then mint a valid token

delete

jennifer
web.delete(app as App, pattern as string, handler as func)

Register a DELETE handler for a pattern, returning a new App.

app
the router to extend
pattern
the route pattern, with optional :param segments
handler
the handler func value
Returns App
a new App with the route added

etag

jennifer
web.etag(ctx as Context, tag as string)

Set an ETag and honour a conditional GET. Delegates to the engine's httpd.etag: sets the ETag response header to tag (quoted) and, if the request's If-None-Match matches, answers 304 Not Modified (412 for a method other than GET / HEAD) and returns true - the handler should then stop. Returns false when the client has no matching cached copy, so the handler sends the full body. The engine handles the RFC 7232 comma-list and weak-validator (W/) forms a proxy may add. tag is the app's choice of validator: a content hash (via hash), a row version, an mtime - so web needs no hashing of its own.

ctx
the request context
tag
the entity tag identifying this version of the response
Returns bool
true if a 304 was sent (stop), false to send the full response

form

jennifer
web.form(ctx as Context)

Parse an application/x-www-form-urlencoded request body into a map of decoded field names to values. Strict: a % without two hex digits, or a body or decoded value that is not UTF-8, throws a WebError with status 400, which the safety net answers as such unless the handler catches it.

ctx
the request context
Returns map of string to string
the form fields
Throws WebError
kind "web", status 400, for a malformed body; kind "limit", status 413, past 10000 fields

formValue

jennifer
web.formValue(ctx as Context, name as string)

Return one form field's value, or "" when absent.

ctx
the request context
name
the field name
Returns string
the field value, or "" when absent

get

jennifer
web.get(app as App, pattern as string, handler as func)

Register a GET handler for a pattern, returning a new App.

app
the router to extend
pattern
the route pattern, with optional :param segments
handler
the handler func value
Returns App
a new App with the route added

header

jennifer
web.header(ctx as Context, name as string)

Return a request header value.

ctx
the request context
name
the header name
Returns string
the header value, or "" if absent

html

jennifer
web.html(ctx as Context, status as int, body as string)

Answer with a text/html body.

ctx
the request context
status
the HTTP status code
body
the HTML body

isOpen

jennifer
web.isOpen(ctx as Context)

Whether the request is still waiting for its answer. False once it has been answered - by the handler, or by the server itself after the respond timeout (httpd.Options.respondTimeoutMs, 60 s by default), when the client already got a 503. A slow handler can check it before work whose reply could no longer be sent.

ctx
the request context
Returns bool
true while a reply can still be sent

joinRoute

jennifer
web.joinRoute(prefix as string, pattern as string)

Concatenate a mount prefix and a route pattern into one clean pattern: drops empty segments (so stray or doubled slashes never matter) and always yields a single leading slash. :param and trailing *wildcard segments carry no slash, so they pass through intact. "" + "/deck" -> "/deck"; "/v1" + "/" -> "/v1"; "" + "" -> "/". Exposed so a layer above (e.g. webapi) can reconstruct the full pattern a mounted route is served under.

prefix
the mount prefix
pattern
the route pattern
Returns string
the joined pattern

method

jennifer
web.method(ctx as Context)

Return the request's HTTP method.

ctx
the request context
Returns string
the HTTP method (e.g. "GET")

mount

jennifer
web.mount(app as App, prefix as string, sub as App)

Mount a sub-router's routes under a path prefix, returning a new App. Every route in sub is re-registered on app with prefix prepended to its pattern (web.mount($app, "/v1", $apiV1) serves apiV1's /deck at /v1/deck). A prefix of "" (or "/") mounts at the root, so the same sub-router can be mounted under several prefixes to serve one route set at many base paths.

Only the sub-router's routes are composed; app-level middleware, the not-found handler, CORS, and the error handler stay app's. :param and trailing *wildcard segments are preserved.

app
the router to extend
prefix
the base path to mount under ("" / "/" = root)
sub
the sub-router whose routes are mounted
Returns App
a new App with the sub-router's routes added under the prefix

multipartForm

jennifer
web.multipartForm(ctx as Context)

Parse a multipart/form-data request body (a file-upload form) into its parts, using the request's Content-Type header (with the boundary) and the raw body. The completion of the body-parser family alongside web.form (urlencoded) and web.bodyJson (JSON). Each multipart.Part is a field or a file (multipart.isFile / multipart.text distinguish them); the handler imports multipart.j to name the type. A missing boundary or a malformed part throws a WebError with status 400, which the safety net answers as such unless the handler catches it.

ctx
the request context
Returns list of multipart.Part
the form parts (fields and files)
Throws WebError
kind "web", status 400, for a malformed body; kind "limit", status 413, past the part caps

new

jennifer
web.new()

Return an empty App with no routes or middleware.

Returns App
a fresh, empty router

notFound

jennifer
web.notFound(app as App, handler as func)

Set a custom handler for unmatched requests (default: a plain 404).

app
the router to extend
handler
the not-found handler func value
Returns App
a new App with the not-found handler set

onError

jennifer
web.onError(app as App, handler as func)

Register an error handler, returning a new App. When a handler or middleware throws, web catches it (so one failing request never stops the server) and answers it: a WebError with its 4xx status (400 for a body that cannot be read, 413 for one past a body parser's cap), anything else with 500, written to stderr. Any other "limit" is a cap the server hit on its own work (an outbound response, a query result, the allocation budget), so it is a 500 too. It then also invokes this handler with the thrown value - the Error struct {kind, message, file, line, col} for a runtime failure or a thrown Error (which crosses the module boundary intact, so the handler may declare its parameter as Error; a module's error struct such as WebError arrives as an Error with its kind and message; any other thrown value is delivered as it is). The hook is additive: stderr always gets a 500's error, so registering a handler adds alerting / structured logging without ever losing the default diagnostic. The handler cannot change the response; it is for observability. An error from the error handler is itself caught and logged, never re-raised. The handler sees client faults (4xx) too, so a client can call it once per malformed request; for a hook that pages or sends mail, register it with web.onServerError instead.

app
the router to extend
handler
the error-handler func value
Returns App
a new App with the error handler set

onServerError

jennifer
web.onServerError(app as App, handler as func)

Register an error handler for server faults only, returning a new App: as web.onError, but the handler is not called for an error answered with a 4xx (a body that cannot be read, a request body past a cap, a WebError with a 4xx status), so clients cannot drive it. It replaces a handler set with web.onError, and the other way round.

app
the router to extend
handler
the error-handler func value
Returns App
a new App with the error handler set

param

jennifer
web.param(ctx as Context, name as string)

Return a captured path parameter, or "" if the route had none by that name.

ctx
the request context
name
the path parameter name
Returns string
the captured value, or "" if absent

patch

jennifer
web.patch(app as App, pattern as string, handler as func)

Register a PATCH handler for a pattern, returning a new App.

app
the router to extend
pattern
the route pattern, with optional :param segments
handler
the handler func value
Returns App
a new App with the route added

path

jennifer
web.path(ctx as Context)

Return the request's URL path.

ctx
the request context
Returns string
the request path

post

jennifer
web.post(app as App, pattern as string, handler as func)

Register a POST handler for a pattern, returning a new App.

app
the router to extend
pattern
the route pattern, with optional :param segments
handler
the handler func value
Returns App
a new App with the route added

put

jennifer
web.put(app as App, pattern as string, handler as func)

Register a PUT handler for a pattern, returning a new App.

app
the router to extend
pattern
the route pattern, with optional :param segments
handler
the handler func value
Returns App
a new App with the route added

query

jennifer
web.query(ctx as Context, name as string)

Return a query-string parameter value.

ctx
the request context
name
the query parameter name
Returns string
the parameter value, or "" if absent

rawQuery

jennifer
web.rawQuery(ctx as Context)

Return the whole query string as the client sent it, without the "?": still percent-encoded, with every key and repeated key in order. Use it to rebuild a URL faithfully (a redirect that keeps the query); query reads one value.

ctx
the request context
Returns string
the raw query string, or "" if the request has none

redirect

jennifer
web.redirect(ctx as Context, status as int, location as string)

Redirect to location with the given status (301 / 302 / 303 / 307 / 308).

ctx
the request context
status
the redirect status code
location
the target URL for the Location header

remoteAddr

jennifer
web.remoteAddr(ctx as Context)

Return the client's network address (host:port).

ctx
the request context
Returns string
the remote address

remoteHost

jennifer
web.remoteHost(ctx as Context)

Return the client's host without the port: 192.0.2.7 for 192.0.2.7:53412, 2001:db8::1 for [2001:db8::1]:53412. The port changes with every new connection, so key anything per client (a rate limit, an allow-list, a log line) on this, not on remoteAddr. This is the peer the server sees; behind a reverse proxy that is the proxy.

ctx
the request context
Returns string
the remote host

renewSession

jennifer
web.renewSession(ctx as Context, cookieName as string)

Rotate the session id: mint a fresh UUID, set it as the session cookie, and return the new id. Call this right after any privilege change - a successful login, a logout, a role change - so a session id an attacker may have fixed before authentication is thrown away. This is the standard session-fixation defence; the application must also move its own session data to the new id.

ctx
the request context
cookieName
the session-id cookie name (e.g. "sid")
Returns string
the freshly minted session id

respond

jennifer
web.respond(ctx as Context, status as int, body as string)

Answer the request with a status code and body.

ctx
the request context
status
the HTTP status code
body
the response body

route

jennifer
web.route(app as App, method as string, pattern as string, handler as func)

Register a handler for a method + pattern, returning a new App.

app
the router to extend
method
the HTTP method to match
pattern
the route pattern, with optional :param segments
handler
the handler func value
Returns App
a new App with the route added

run

jennifer
web.run(app as App, addr as string)

Listen on addr and serve forever, dispatching each request to its matched handler. Blocks; interrupt to stop.

app
the router
addr
the listen address (e.g. ":8080")

sendGzip

jennifer
web.sendGzip(ctx as Context, status as int, body as string)

Answer with a body, gzip-compressed when the client accepts it. Sets Vary: Accept-Encoding always; if the request's Accept-Encoding names gzip, the body is compressed and sent with Content-Encoding: gzip, otherwise it is sent as-is. Set the Content-Type yourself (via web.setHeader) before calling. Worth it for large text / JSON / HTML; skip it for already-compressed payloads (images, archives).

ctx
the request context
status
the HTTP status code
body
the response body

sendJson

jennifer
web.sendJson(ctx as Context, status as int, doc as json.Value)

Answer with an application/json body encoded from a json.Value. (Named sendJson, not json, because a function may not shadow the json namespace this module imports.)

ctx
the request context
status
the HTTP status code
doc
the JSON document to encode

serveDir

jennifer
web.serveDir(ctx as Context, root as string)

Serve static files from a directory root (path-safe; 404 for a missing file, a dotfile other than .well-known/, or a directory without an index.html).

ctx
the request context
root
the directory to serve from

serveFile

jennifer
web.serveFile(ctx as Context, path as string)

Answer with a file from disk.

ctx
the request context
path
the filesystem path to serve

serveOn

jennifer
web.serveOn(app as App, srv as httpd.Server)

Serve on an already-listening httpd.Server, dispatching each request to its matched handler. Blocks until the server is shut down (httpd.accept then errors and the loop exits). Use this when you want to hold the server handle yourself - e.g. to shut it down from another task, or to serve from a spawn. web.run is the listen-and-serve convenience over it.

app
the router
srv
the already-listening server handle

sessionId

jennifer
web.sessionId(ctx as Context, cookieName as string)

Return the request's session id, minting a new one on first use. If the cookieName cookie is present its value is returned; otherwise a fresh UUID v4 (crypto-grade random, so unguessable as a session token) is generated and set as a Secure, HttpOnly, SameSite=Lax, path-/ cookie (Secure is on by default; set JENNIFER_WEB_INSECURE_COOKIES=1 for local plaintext-HTTP dev). web manages only the id cookie - the session data itself lives in a store the app owns (e.g. the session module over memcache), so web forces no store or network dependency. Call once per request and capture the returned id.

ctx
the request context
cookieName
the session-id cookie name (e.g. "sid")
Returns string
the session id (existing or newly minted)

setCookie

jennifer
web.setCookie(
    ctx as Context,
    name as string,
    value as string,
    opts as CookieOptions)

Set a response cookie with the given attributes (a Set-Cookie header).

ctx
the request context
name
the cookie name
value
the cookie value
opts
the cookie attributes (zero-value = a session cookie)

setHeader

jennifer
web.setHeader(ctx as Context, name as string, value as string)

Set a response header.

ctx
the request context
name
the header name
value
the header value

text

jennifer
web.text(ctx as Context, status as int, body as string)

Answer with a text/plain body.

ctx
the request context
status
the HTTP status code
body
the response body

Structs

App

The value-semantic router state: the routes, the middleware chain (handler func values run before each route), and an optional not-found handler (hasNotFound false = the built-in 404). Every registrar returns a fresh App.

jennifer
def struct App {
    routes as list of Route,
    middleware as list of func,
    notFound as func,
    hasNotFound as bool,
    cors as CorsOptions,
    onError as func,
    hasOnError as bool,
    onErrorClient as bool,
    allocBudget as int
};
routes
the registered routes
middleware
handler func values run before each route
notFound
the not-found handler (only when hasNotFound)
hasNotFound
whether a custom not-found handler is set (else built-in 404)
cors
the CORS policy applied by the serve loop (zero-value = off)
onError
the error-handler (only when hasOnError); see web.onError
hasOnError
whether an error handler is set (stderr always logs regardless)
onErrorClient
whether the error handler also sees client faults (answered 4xx): true for web.onError, false for web.onServerError
allocBudget
the per-request allocation budget in bytes (0 = none); see web.allocBudget

BasicCredentials

Parsed HTTP Basic credentials from the request. present is false when the request carried no valid Authorization: Basic header.

jennifer
def struct BasicCredentials {
    user as string,
    password as string,
    present as bool
};
user
the username
password
the password
present
true when valid Basic credentials were supplied

Context

What a handler receives: the underlying request handle plus the path parameters captured from the matched route (:id -> params["id"]).

jennifer
def struct Context {
    req as httpd.Request,
    params as map of string to string
};
req
the underlying request handle
params
the captured path parameters

CookieOptions

Attributes for a Set-Cookie header. A zero-value struct is a session cookie (no attributes); set the fields you need.

jennifer
def struct CookieOptions {
    path as string,
    domain as string,
    maxAge as int,
    httpOnly as bool,
    secure as bool,
    sameSite as string
};
path
the Path attribute ("" omits it)
domain
the Domain attribute ("" omits it)
maxAge
the Max-Age in seconds; 0 omits it, a negative value expires the cookie now
httpOnly
add HttpOnly (hide the cookie from JavaScript)
secure
add Secure (send only over HTTPS)
sameSite
the SameSite attribute: "Lax", "Strict", "None", or "" to omit (any other value throws kind "web"; "None" requires secure)

CorsOptions

A cross-origin (CORS) policy. When set on an App via web.cors, the serve loop adds the Access-Control-* headers to every response and answers a preflight OPTIONS request with 204. A zero-value struct (empty allowOrigin) leaves CORS off.

jennifer
def struct CorsOptions {
    allowOrigin as string,
    allowMethods as string,
    allowHeaders as string,
    allowCredentials as bool,
    maxAge as int
};
allowOrigin
the Access-Control-Allow-Origin value ("*" or an origin; "" = off)
allowMethods
the Access-Control-Allow-Methods value ("" omits it)
allowHeaders
the Access-Control-Allow-Headers value ("" omits it)
allowCredentials
add Access-Control-Allow-Credentials: true
maxAge
the Access-Control-Max-Age in seconds (0 omits it)

Route

One registered (method, pattern, handler) triple. Exported only to satisfy the referential-closure rule (App exposes a list of Route); programs never build one directly - they call web.get / web.route.

jennifer
def struct Route {
    method as string,
    pattern as string,
    handler as func,
    segs as list of string
};
method
the HTTP method (e.g. "GET")
pattern
the route pattern, with optional :param segments
handler
the handler func value to dispatch to
segs
the pattern split into segments once, when the route is registered, so a request does not split every pattern again

WebError

The error web throws, for every error of kind "web": a request body that cannot be read (status 400) or a misconfiguration (status 500). A body parser (bodyJson, form, multipartForm) also throws it, with kind "limit" and status 413, for a request body past one of its caps. One that escapes a handler or middleware is answered with its status; a 4xx is answered without the 500 error dump.

jennifer
def struct WebError {
    kind as string,
    message as string,
    status as int
};
kind
"web", or "limit" for a request body past a parser cap
message
what went wrong
status
the HTTP status the safety net answers it with