Server

~import orisha/index

Orisha — the contract.

lib/index.k · 26 tors

Orisha — the contract. · 40 more lines
Orisha — the contract. Everything Orisha declares lives here, and nothing in this file is Zig, so there is no parser to switch out of and not a single `~` anywhere. The Zig that implements it — the socket calls, the request parser, the router transform — sits in the companion `index.kz` beside this file. Same stem, same module: the compiler merges them. That split is the whole reason this file reads the way it does. These declarations used to live inside 1,056 lines of Zig, which forced a `~` onto every one of them; the character was never about the Koru, it was about the host language it was sharing a file with. Public API: orisha:serve(port) - Start server (calls abstract handler for each request) orisha:handler - Abstract event users implement for request handling orisha:router(req) - Pattern-branch router transform orisha:static(name, root, ...) - Declare static files to embed at compile time orisha:static-router(name) - Transform: inline static file lookup + fallback orisha:header(req, name) - One request header, scanned lazily -> ?string orisha:cookie(req, name) - One pair out of the Cookie header -> ?string orisha:form(req, name) - One urlencoded field out of req.body -> ?string orisha:query-param(req, name) - The same codec over req.query -> ?string Response.extra_headers - CRLF block of response headers (Location, Set-Cookie, ...) spliced into the head Example (simplest server): ~orisha:handler -> { status: 200, body: "Hello!", content_type: "text/plain" } ~orisha:serve(port: 3001) Example (API + static): ~orisha:handler = orisha:router(req) ! [GET /api/health] -> { status: 200, body: "ok", content_type: "application/json" } ! [*] |> orisha:static-router(name: "site") Example (pure static site): ~import orisha ~orisha:static(name: "site", root: "build", fallback: "200.html") ~orisha:handler = orisha:static-router(name: "site") ~orisha:serve(port: 3000)

handler

abstractretain lib/index.k:82

handler-lite

abstractretain lib/index.k:98

init

abstract lib/index.k:118

release-body

lib/index.k:166

serve-file

lib/index.k:176

grpc-sum-reply

lib/index.k:188

query-param

lib/index.k:220

ws-accept

lib/index.k:262

generation-bump

lib/index.k:273

router

comptimetransform lib/index.k:338

static

comptime lib/index.k:356

static-router

comptimetransform lib/index.k:370