FlareHttpContext
class FlareHttpContextFull HTTP context passed to controllers, middleware, and handler functions.
Wraps the inbound FlareRequest (available as req) and exposes pipeline-scoped concerns: request state, parsed contract data via extract, and outbound cookie management via cookies.
How you get one
Section titled “How you get one”Handed to you by the framework; see Requests.
Properties
Section titled “Properties”req: FlareRequestAccessors
Section titled “Accessors”cookies
Section titled “cookies”get cookies(): FlareCookiesreturns FlareCookies
get state(): RequestStatereturns RequestState
Methods
Section titled “Methods”extract()
Section titled “extract()”extract<T extends RequestDescriptor>(descriptor: T): TypedRequestContext<T>Extracts the parsed and validated request inputs typed against a contract descriptor.
Pass a single method entry from a ContractToken and receive an object
whose body, route, and query properties are fully typed according to what
the descriptor declares. Fields not present in the descriptor resolve to never.
Zero-cost cast at runtime: no additional parsing is performed. Parsing and validation happen once in the pipeline before the handler runs.
descriptor T
returns TypedRequestContext<T>
Example:
const { body, route, query } = ctx.extract(UserContract.getUser);sse(producer: (sse: SseWriter, signal: AbortSignal) => void | Promise<void>): FlareResponseOpens a Server-Sent Events response and runs producer as the event source.
The response returns immediately with Content-Type: text/event-stream; the
producer pushes frames through the SseWriter, which paces itself
against the connection (one frame buffered). The stream ends when the
producer settles or the request aborts; the producer’s signal is the
request’s AbortSignal, so a long-lived loop can stop when the client leaves.
producer (sse: SseWriter, signal: AbortSignal) => void | Promise<void>
returns FlareResponse
Example:
return ctx.sse(async (sse, signal) => { while (!signal.aborted) { await sse.send({ event: "tick", data: { now: Date.now() } }); await delay(1000); }});Learn: Requests