API reference
The flare package, from flare_mlake 0.13.2, as published on mojoshelf (commit b1371866a784), by mojo doc from Mojo 1.2.0.
Source.
flare -- a Mojo full networking stack in one library.
HTTP/1.1 + HTTP/2 server and client, WebSocket server and
client (RFC 6455), TLS 1.2/1.3 (OpenSSL with ALPN), TCP, UDP,
DNS. The HTTP server and client are version-aware:
HttpServer.serve(handler) peeks the first 24 bytes of every
accepted connection and dispatches HTTP/1.1 or HTTP/2 to the
same handler. HttpClient.get("https://...") advertises ALPN
["h2", "http/1.1"] and switches wires from what the server
picks. The application surface (Router,
middleware, typed extractors, Auth, Session) doesn't
know which wire is talking to it.
Small FFI footprint: libc syscalls, OpenSSL for TLS, zlib + brotli for content encoding. No HTTP framework dependency.
from flare import HttpServer, Router, Request, Response, ok, SocketAddr
def hello(req: Request) raises -> Response:
return ok("hello")
def main() raises:
var r = Router()
r.get("/", hello)
var srv = HttpServer.bind(SocketAddr.localhost(8080))
srv.serve(r^, num_workers=4)
What flare is
One reactor per worker (kqueue on macOS, epoll on
Linux, opt-in io_uring on Linux >= 6.0 via
FLARE_BUFRING_HANDLER=1), a Handler trait that takes plain def functions
or compiled-down structs, an RFC 7230 parser under continuous fuzzing (62
fuzz harnesses across the tree, 9M+ runs combined, zero known crashes), and a Cancel token plumbed to handlers via
CancelHandler. num_workers=1 is a single-threaded
reactor; num_workers=N with N >= 2 runs N
workers (on Mojo's AsyncRT pool) behind per-worker SO_REUSEPORT listeners by default
(matches actix_web's listener strategy and gives the highest
steady-state throughput). Set FLARE_REUSEPORT_WORKERS=0 to
opt into the single shared listener with EPOLLEXCLUSIVE --
trades 7-22 % req/s (handler vs static fast path) for a
uniformly tighter p99.99 tail under sustained load. See
docs/benchmark.md for the head-to-head numbers. Static
endpoints can skip the parser entirely with
serve_static(resp, num_workers=N).
The operational core: per-request / handler / body-read deadlines,
HttpServer.drain(timeout_ms) for graceful shutdown, sanitised
error responses, Request.peer threaded from the accept path,
zero-copy reads (RequestView[origin] + ViewHandler),
streaming response primitives (Body / ChunkSource /
StreamingResponse[B]; stream_response(source) streams the same
handler byte-identically over h1 / h2 / h3 / https), and server-side
TLS (TlsAcceptor over OpenSSL, plus in-process HTTPS termination
via HttpServer.bind_tls + serve).
The application layer: Router with path params, typed
extractors (PathInt / QueryInt /
HeaderStr / Form / Multipart / Cookies / ...),
generic middleware (Logger / RequestId / Compress /
CatchPanic), Cors, FileServer with HEAD + Range,
gzip + brotli content negotiation, RFC 6265 cookie jars,
HMAC-SHA256 signed cookies, and signed Session stores.
Architecture
flare.io - BufReader
flare.ws - WebSocket client + server (RFC 6455, permessage-deflate
with context-takeover, WS-over-h2 via RFC 8441 and
WS-over-h3 via RFC 9220 Extended CONNECT)
flare.http2 - HTTP/2 frame codec + HPACK (with table-driven Huffman
fast decoder) + h2c upgrade (RFC 9113 / 7541)
flare.http - HTTP/1.1 client + reactor server + Router /
extractors + middleware (Logger / RequestId / Compress /
Cors / Retry / PostHocDeadline / Conditional) + FileServer +
forms + cookies + sessions + content-encoding + SSE
+ template engine with {% block %} / {% extends %}
inheritance + serve_streaming streaming-proxy surface
(StreamHandler / StreamConn, UpstreamChunkSource,
watermark backpressure, admission control) + sans-I/O
parser sublayer under flare.http.proto.*
flare.http.cache - RFC 9111 cache primitives (CacheControl directive
parser, CacheKey, InMemoryCacheStore)
flare.grpc - gRPC primitives on flare.http2: LPM message framing,
canonical Status codes (with optional
``grpc-status-details-bin`` payload), Metadata
carrier, the unary server adapter
(``GrpcRequestHeaders`` typed request-headers
carrier -> ``GrpcUnaryReply`` typed handler return
(``ok`` / ``err`` factories) -> ``run_unary_call``
never-raises orchestrator that maps header / LPM /
handler failures to typed ``INVALID_ARGUMENT`` /
``INTERNAL`` outcomes), and a ``GrpcClient`` that
drives unary RPCs over the ``HttpClient`` HTTP/2 path
plus server- / client- / bidi-streaming RPCs
(``GrpcServerStream`` / ``GrpcBidiStream``) that
surface LPM messages incrementally on a long-lived
HTTP/2 stream
flare.openapi - OpenAPI 3.1 spec model + deterministic JSON emitter
flare.quic - Sans-I/O QUIC v1 codec primitives (varint, long /
short packet headers, all 22 RFC 9000 §19 transport
frames dispatched via the ``FrameHandler`` trait +
``parse_frame_into[H]`` (per-type callbacks; no
intermediate union carrier), with per-type
``encode_*(payload, mut out: List[UInt8])`` writers,
RFC 9000 §18 transport parameters, and RFC 9000 §3 /
§13 connection + stream state machines, plus the live
``QuicListener`` UDP reactor, the ``QuicClientConnection``
client driver (incl. resumption + 0-RTT EarlyData
send flight, NEW_TOKEN, ECN, ACK_FREQUENCY and path-MTU
discovery), and the rustls QUIC TLS drive that
carry HTTP/3 end-to-end
flare.http3 - Sans-I/O HTTP/3 frame codec, SETTINGS payload,
request-stream reader (``Http3RequestReader`` +
``Http3RequestEventHandler`` + ``feed_into[H]`` --
typed ``on_headers`` / ``on_data`` / ``on_trailers``
callbacks), response-stream writer with QPACK-
encoded field sections and the ``mut out:
List[UInt8]`` buffer-reuse contract (RFC 9114 §4 +
§7), plus the client side: ``Http3ClientConnection``
(request writer + response reader over the QUIC
client driver) for end-to-end HTTP/3 requests,
including ``fetch_0rtt`` -- idempotent-method-only
0-RTT: emits the request in the first EarlyData flight
on a resumed connection and transparently replays it
at 1-RTT if the server rejects early data
flare.qpack - Sans-I/O static-only QPACK encoder / decoder for
HTTP/3 field sections (RFC 9204 Appendix A static
table + literal + Huffman, shared with HPACK)
flare.crypto - HMAC-SHA256, base64url
flare.tls - TLS 1.2/1.3 (OpenSSL, client + server, ALPN, session resumption,
SNI certificates, certificate hot reload)
flare.tcp - TcpStream + TcpListener (IPv4 + IPv6)
flare.udp - UdpSocket (IPv4 + IPv6)
flare.uds - UnixListener + UnixStream (AF_UNIX sidecar IPC);
FrameMux / FrameDemux multiplex logical streams over
one UnixStream (encode_frame / decode_frame)
flare.dns - getaddrinfo (dual-stack) + an additive TTL
``DnsCache`` over the sync resolver, plus an
off-reactor ``resolve_async`` (getaddrinfo on a pool
thread) and ``order_happy_eyeballs`` address ordering
flare.net - IpAddr, SocketAddr, RawSocket
flare.runtime - Reactor (kqueue / epoll, opt-in io_uring on Linux),
TimerWheel, Scheduler, HandoffQueue +
WorkerHandoffPool, BufferPool, vectored I/O
flare.testing - TestClient[H] (in-process handler exerciser) +
fork_server / kill_forked_server for integration tests
flare.utils - POSIX FFI thunks (fork / waitpid / kill / usleep /
exit / getpid) the Mojo stdlib doesn't expose yet
Each layer mostly imports from layers below it. The runtime
scheduler is generic over a Frontend trait so that
flare.runtime no longer imports from flare.http; the HTTP
worker bring-up lives in flare.http.multicore and plugs into
the scheduler via that trait. flare.http still re-imports
flare.http2 for the unified reactor dispatch (the only
remaining intra-http cycle, tracked as cleanup in the source).
HTTP requests
from flare.http import get, post
def main() raises:
var resp = get("https://httpbin.org/get")
print(resp.status, resp.ok()) # 200 True
var r = post("https://httpbin.org/post", '{"hello": "flare"}')
r.raise_for_status()
var data = r.json()
print(data["json"]["hello"].string_value())
post with a String body sets Content-Type: application/json
automatically.
The server-side sections below build gradually: each one adds one new concept on top of the previous example.
Routing: Router
One event loop (kqueue on macOS, epoll on Linux), non-blocking sockets,
a per-connection state machine, a hashed timing wheel for idle
timeouts. Routes carry path parameters (:name) and methods;
unknown paths return 404, known paths with the wrong method return 405
with an auto-generated Allow: header.
from flare.http import Router, Request, Response, ok, HttpServer
from flare.net import SocketAddr
def home(req: Request) raises -> Response:
return ok("home")
def get_user(req: Request) raises -> Response:
return ok("user " + req.param("id"))
def create_user(req: Request) raises -> Response:
return ok("created")
def main() raises:
var r = Router()
r.get("/", home)
r.get("/users/:id", get_user)
r.post("/users", create_user)
var srv = HttpServer.bind(SocketAddr.localhost(8080))
srv.serve(r^)
Typed inputs: Extracted[H]
Declare the handler's extractors as the fields of a Handler struct
and wrap it in Extracted[H]. The adapter reflects on the struct's
field types at compile time to pull each one from the request before
calling the inner serve. Parse failures become automatic 400
responses; serve is only reached when every field has a value of
the right type.
from flare.http import (
Router, Handler, Request, Response, ok, HttpServer,
Extracted, PathInt, OptionalQueryInt, HeaderStr,
)
from flare.net import SocketAddr
@fieldwise_init
struct GetUser(Copyable, Defaultable, Handler):
var id: PathInt["id"]
var page: OptionalQueryInt["page"]
var auth: HeaderStr["Authorization"]
def __init__(out self):
self.id = PathInt["id"]()
self.page = OptionalQueryInt["page"]()
self.auth = HeaderStr["Authorization"]()
def serve(self, req: Request) raises -> Response:
return ok("user=" + String(self.id.value))
def main() raises:
var r = Router()
r.get("/users/:id", Extracted[GetUser]())
var srv = HttpServer.bind(SocketAddr.localhost(8080))
srv.serve(r^)
The concrete PathInt / PathStr / QueryInt / HeaderStr
/ etc. extractors expose .value directly as the parsed primitive.
Custom types are handled by writing your own Extractor struct.
Value-constructor extractors (PathInt["id"].extract(req)) are
also available for use inside plain def handlers when the
struct shape is overkill.
Static route tables: ComptimeRouter
Same routing surface as Router, but the route list is a
compile-time value. Segment parsing happens at build time and the
dispatch loop unrolls per route, so the runtime does zero
string-compares on unknown paths.
from flare.http import (
ComptimeRoute, ComptimeRouter, Request, Response, Method, ok, HttpServer,
)
from flare.net import SocketAddr
def home(req: Request) raises -> Response:
return ok("home")
def get_user(req: Request) raises -> Response:
return ok("user=" + req.param("id"))
def create_user(req: Request) raises -> Response:
return ok("created")
comptime ROUTES: List[ComptimeRoute] = [
ComptimeRoute(Method.GET, "/", home),
ComptimeRoute(Method.GET, "/users/:id", get_user),
ComptimeRoute(Method.POST, "/users", create_user),
]
def main() raises:
var r = ComptimeRouter[ROUTES]()
var srv = HttpServer.bind(SocketAddr.localhost(8080))
srv.serve(r^)
Shared state via captured handlers
When a handler needs application-scoped state, build a wrapping
Handler struct that captures the state by value. Middleware
itself is a Handler that holds another Handler, so you
stack layers by nesting constructors, no callback chain to
thread through.
from flare.http import Router, Request, Response, Handler, ok, HttpServer
from flare.net import SocketAddr
@fieldwise_init
struct Counters(Copyable):
var hits: Int
def home(req: Request) raises -> Response:
return ok("home")
@fieldwise_init
struct WithHits[Inner: Handler](Handler):
var inner: Self.Inner
var counters: Counters
def serve(self, req: Request) raises -> Response:
var resp = self.inner.serve(req).lower()
resp.headers.set("X-Hits", String(self.counters.hits))
return resp^
def main() raises:
var router = Router()
router.get("/", home)
var srv = HttpServer.bind(SocketAddr.localhost(8080))
srv.serve(WithHits(inner=router^, counters=Counters(hits=37)))
Scale knob: num_workers
Every server example above takes an optional num_workers. At
1 (the default) it's the single-threaded reactor. Set it to
default_worker_count() and flare runs N workers,
each with its own reactor + timer wheel, with per-core pinning
on Linux. The handler type is unchanged.
By default each worker binds its own SO_REUSEPORT
listener (the kernel hashes new 4-tuples to one of N
listeners; matches actix_web's listener strategy and gives
the highest steady-state throughput on dev-box workloads).
Export FLARE_REUSEPORT_WORKERS=0 before launch to
opt back into the single shared listener with
EPOLLEXCLUSIVE -- 7-22 % less req/s (handler vs static
fast path) for a uniformly tighter p99.99 σ under sustained
load (the kernel offers each accept event to whichever
worker is currently parked in epoll_wait, so idle
workers absorb spikes). See docs/benchmark.md
for the head-to-head numbers and the rationale.
from flare.http import HttpServer, Router, Request, Response, ok
from flare.net import SocketAddr
from flare.runtime import default_worker_count
def hello(req: Request) raises -> Response:
return ok("hello")
def main() raises:
var r = Router()
r.get("/", hello)
var srv = HttpServer.bind(SocketAddr.localhost(8080))
srv.serve(r^, num_workers=default_worker_count())
pin_cores=True (default) pins worker N to core N % num_cpus()
on Linux and is a no-op on macOS. Upper bound on num_workers is
256.
Fixed-body endpoints: serve_static
For endpoints that always return the same bytes (health checks, TFB
plaintext, single-URL microservices), precompute_response builds
the full HTTP wire form at startup and HttpServer.serve_static
runs a specialised reactor that skips the parser's Request-construction
and handler-dispatch step entirely.
from flare.http import HttpServer, precompute_response
from flare.net import SocketAddr
def main() raises:
var resp = precompute_response(
status=200,
content_type="text/plain; charset=utf-8",
body="Hello, World!",
)
var srv = HttpServer.bind(SocketAddr.localhost(8080))
srv.serve_static(resp)
Keep-alive and Connection: close wire forms are both pre-encoded;
the reactor picks the right one per request from the parsed Connection
header. serve_static(resp, num_workers=N) fans the same fast path
out across N worker threads, each with its own listener.
Comptime config checks
ServerConfig.check[config]() validates a comptime ServerConfig
through Mojo comptime assert so misconfigured servers fail the
build rather than the first request:
from flare.http import HttpServer, Request, Response, ok
from flare.http.handler import FnHandler
from flare.http.server import ServerConfig
from flare.net import SocketAddr
def hello(req: Request) raises -> Response:
return ok("hello")
comptime CONFIG: ServerConfig = ServerConfig(
max_header_size=4096,
max_body_size=64 * 1024, # must be >= max_header_size (compile time)
max_keepalive_requests=1000,
idle_timeout_ms=30_000,
)
def main() raises:
ServerConfig.check[CONFIG]()
var srv = HttpServer.bind(SocketAddr.localhost(8080), materialize[CONFIG]())
srv.serve(FnHandler(hello))
Break any invariant (e.g. max_body_size < max_header_size) and Mojo
rejects the build with a pointed error. The impossible state doesn't
compile, so no runtime guard is needed.
HTTP client with auth
from flare.http import HttpClient, BasicAuth, BearerAuth
def main() raises:
var client = HttpClient("https://api.example.com", BearerAuth("tok_abc"))
var items = client.get("/items").json()
client.post("/items", '{"name": "new"}').raise_for_status()
HTTP/2: same client, same server, version-aware
There is no separate Http2Client / Http2Server to learn:
the same :class:flare.http.HttpClient and
:class:flare.http.HttpServer are HTTP-version-aware internally.
from flare.http import HttpClient
def main() raises:
# https:// auto-negotiates via TLS+ALPN. If the server picks
# h2 the request is driven through HTTP/2 internally; if it
# picks http/1.1 (or doesn't speak ALPN at all) the
# existing HTTP/1.1 wire is used. Either way you get a
# flare.http.Response back.
with HttpClient() as c:
var r = c.get("https://nghttp2.org/")
print(r.status, r.text())
# http:// is HTTP/1.1 by default; opt into HTTP/2 cleartext
# via prior knowledge with prefer_h2c=True:
with HttpClient(prefer_h2c=True, base_url="http://localhost:8080") as c:
var r = c.get("/api/users")
r.raise_for_status()
# https:// can prefer HTTP/3 over QUIC with prefer_http3=True. The
# same call site applies; an idempotent GET races h3 against h2/h1
# (happy-eyeballs) and any QUIC failure falls back transparently:
with HttpClient(prefer_http3=True, base_url="https://cloudflare.com") as c:
var r = c.get("/")
print(r.status, r.text())
The client surface is additive and composable: with_redirect_policy,
with_retry, with_cookies, and with_pool chain off the
constructor, and auto_decompress (default on) transparently decodes
gzip / deflate / br responses. The H3 / QUIC client drivers
stay internal -- you reach HTTP/3 through HttpClient, never a
separate type.
The server side is symmetric -- one accept loop dispatches both
wires per connection (preface peek for cleartext, ALPN h2
for TLS):
from flare.http import HttpServer, Request, Response, ok
from flare.net import SocketAddr
def hello(req: Request) raises -> Response:
return ok("hi")
def main() raises:
var srv = HttpServer.bind(SocketAddr.localhost(8080))
# The same handler is dispatched whether the client speaks
# HTTP/1.1 or HTTP/2 over the same port.
srv.serve(hello, num_workers=4)
WebSocket
from flare.ws import WsClient
def main() raises:
with WsClient.connect("ws://echo.websocket.events") as ws:
ws.send_text("hello")
var msg = ws.recv_message()
if msg.is_text:
print(msg.as_text())
Cookies
from flare.http import Cookie, CookieJar, parse_set_cookie_header
def main() raises:
var jar = CookieJar()
jar.set(Cookie("session", "abc123", secure=True, http_only=True))
print(jar.to_request_header()) # session=abc123
var c = parse_set_cookie_header("id=42; Path=/; Max-Age=3600")
print(c.name, c.value, c.max_age) # id 42 3600
Low-level API
IP addresses and DNS
from flare.net import IpAddr, SocketAddr
from flare.dns import resolve
def main() raises:
var ip = IpAddr.parse("192.168.1.100")
print(ip.is_private()) # True
var addr = SocketAddr.parse("[::1]:8080")
print(addr.ip.is_v6(), addr.port) # True 8080
var addrs = resolve("example.com") # returns both IPv4 and IPv6
print(addrs[0])
TCP
from flare.tcp import TcpStream
def main() raises:
var conn = TcpStream.connect("localhost", 8080)
_ = conn.write("Hello\n".as_bytes())
var buf = List[UInt8](capacity=4096)
buf.resize(4096, 0)
var n = conn.read(buf.unsafe_ptr(), len(buf))
conn.close()
TLS
from flare.tls import TlsStream, TlsConfig
def main() raises:
var tls = TlsStream.connect("example.com", 443, TlsConfig())
_ = tls.write("GET / HTTP/1.0\r\nHost: example.com\r\n\r\n".as_bytes())
tls.close()
WebSocket frames
from flare.ws import WsClient, WsFrame
def main() raises:
var ws = WsClient.connect("ws://echo.websocket.events")
ws.send_text("ping")
var frame = ws.recv()
print(frame.text_payload())
ws.close()
Reactor (advanced)
from flare.runtime import Reactor, Event, INTEREST_READ
def main() raises:
var r = Reactor()
# Register a non-blocking fd; see ``Reactor`` docs for a full example.
Modules
-
flare.cryptoflare.crypto— minimal cryptographic primitives over the OpenSSL FFI. -
flare.crypto.base64flare.crypto.base64-- RFC 4648 §4 standard base64 encode/decode. 2 functions -
flare.crypto.hmacHMAC-SHA256 + URL-safe base64 over the OpenSSL FFI. 4 functions -
flare.crypto.randomflare.crypto.random-- bytes from the operating system's CSPRNG. 2 functions -
flare.dnsDNS resolution viagetaddrinfo(3). -
flare.dns.async_resolveDNS resolution on a separate thread + happy-eyeballs ordering. 2 functions -
flare.dns.cacheTTL-bounded DNS resolution cache. 1 struct -
flare.dns.resolverDNS hostname resolution via libcgetaddrinfo(3). 3 functions -
flare.errorsCross-module typed-error vocabulary for flare. 4 structs · 6 functions -
flare.grpcflare.grpc— gRPC primitives on top of the HTTP/2 reactor. -
flare.grpc.clientThe gRPC unary client over the HTTP/2HttpClientpath. 2 structs -
flare.grpc.client_streamflare.grpc.client_stream-- server-side client-streaming + bidi. 2 structs · 2 traits · 1 function -
flare.grpc.framinggRPClength-prefix-message (LPM) framing codec. 3 structs · 2 functions -
flare.grpc.healthflare.grpc.health-- the standardgrpc.health.v1.Healthservice (Check), implemented as a :trait:GrpcUnaryhandler. 2 structs · 2 functions -
flare.grpc.interceptorflare.grpc.interceptor-- chainable unary server interceptors. 1 struct · 1 trait -
flare.grpc.metadatagRPCmetadata carrier (initial + trailing). 2 structs -
flare.grpc.protoflare.grpc.proto-- proto3 wire-format codec. 2 structs -
flare.grpc.reflectionflare.grpc.reflection-- gRPC server reflection (v1alpha). 3 structs -
flare.grpc.serverflare.grpc.server-- gRPC server adapter on the HTTP/2 reactor. 5 structs · 1 trait · 5 functions -
flare.grpc.server_streamflare.grpc.server_stream-- server-streaming gRPC adapter. 2 structs · 1 trait · 1 function -
flare.grpc.statusgRPCstatus codes and trailer carrier. 1 struct · 2 functions -
flare.grpc.streamingThe gRPC streaming calls over a long-lived HTTP/2 stream. 2 structs -
flare.httpHTTP/1.1 client and server. -
flare.http.alpn_dispatchflare.http.alpn_dispatch-- ALPN-driven wire dispatcher. 1 struct · 4 functions -
flare.http.async_bodyReactor-integrated external streaming source. 2 structs · 1 trait -
flare.http.authHTTP authentication helpers. 2 structs · 1 trait -
flare.http.auth_extractServer-side authentication extractors + CSRF helper. 5 structs · 5 functions -
flare.http.bodyStreaming response body primitives. 2 structs · 2 traits · 1 function -
flare.http.cacheflare.http.cache— RFC 9111 HTTP cache primitives. -
flare.http.cache.controlCache-Controlheader parser (RFC 9111 §5.2). 1 struct · 3 functions -
flare.http.cache.keyCache key derivation (RFC 9111 §4 "Constructing Responses from Caches"). 1 struct · 1 function -
flare.http.cache.middlewareHTTP cache middleware (RFC 9111). 1 struct -
flare.http.cache.storeCache store trait + in-memory implementation. 2 structs · 1 trait -
flare.http.cancelCancel token plumbed from the reactor into request handlers. 3 structs -
flare.http.clientHTTP/1.1 client with optional TLS support. 2 structs -
flare.http.client_poolHTTP/1.1 client connection pool. 1 struct -
flare.http.conditionalConditional GET / PUT middleware (RFC 9110 §13). 2 structs · 1 function -
flare.http.cookieHTTP cookie support (RFC 6265). 3 structs · 2 functions -
flare.http.corsCors[Inner]middleware (Cross-Origin Resource Sharing). 2 structs -
flare.http.encodingHTTP content-encoding helpers: gzip and deflate via zlib FFI. 1 struct · 6 functions -
flare.http.errorHTTP-level error types. 2 structs -
flare.http.extractTyped request extractors with reflective auto-injection. 28 structs -
flare.http.formapplication/x-www-form-urlencodedparsing (WHATWG URL Living Standard, §5.1). 1 struct · 3 functions -
flare.http.frontendHTTP frontends for the multicore :class:flare.runtime.Scheduler. 3 structs -
flare.http.fsFileServer— serve files from a directory with HEAD + Range support. 2 structs · 1 function -
flare.http.handlerTheHandlertrait: flare's request-to-response contract. 5 structs · 5 traits -
flare.http.header_phfComptime perfect-hash dispatch for ~70 standard HTTP header names. 1 struct · 5 functions -
flare.http.header_viewBorrowed header storage. 1 struct · 1 function -
flare.http.headersHTTP header collection with case-insensitive key lookup. 2 structs · 1 function -
flare.http.hpack_huffmanHPACK Huffman codec — RFC 7541 Appendix B. 1 struct · 4 functions -
flare.http.hpack_huffman_simdHPACK Huffman fast decoder. 2 functions -
flare.http.internInternedStaticStringtable for HTTP method names + common header values. 2 structs · 4 functions -
flare.http.metricsPrometheus-text-exposition metrics middleware. 2 structs -
flare.http.middlewareGeneric middleware library for . 5 structs · 1 function -
flare.http.multipartmultipart/form-dataparsing (RFC 7578). 2 structs · 1 function -
flare.http.multipart_builderClient-sidemultipart/form-datarequest-body builder (RFC 7578). 1 struct -
flare.http.protoflare.http.proto-- pure-function HTTP wire codecs and parsers. -
flare.http.proto.asciiflare.http.proto.ascii-- zero-validation ASCII helpers. 3 functions -
flare.http.proto.chunkedSans-I/O framing forTransfer-Encoding: chunkedrequest bodies. 7 functions -
flare.http.proto.h1_leniencyNamed opt-in flags for HTTP/1.1 parser leniency. 1 struct -
flare.http.proto.h2_configHTTP/2 SETTINGS and per-connection limits. 1 struct -
flare.http.proto.h2c_upgradeHTTP/1.1 -> HTTP/2 cleartext (h2c) upgrade detection (RFC 7540 §3.2). 1 function -
flare.http.proto.huffmanCanonical sans-I/O HPACK / QPACK Huffman codec surface (flare.http.proto.huffman) -- RFC 7541 §5.2 + Appendix B. -
flare.http.proto.utf8Lossy UTF-8 decoding for caller-supplied byte bodies. 1 function -
flare.http.proxy_protocolPROXY protocol v1 + v2 parser (HAProxy spec). 2 structs · 3 functions -
flare.http.redirect_policyHTTP redirect policy: configurable cross-origin + auth gating. 4 structs -
flare.http.reliabilityReliability middleware:Retry/PostHocDeadline/RateLimit/CircuitBreakerpolicies. 5 structs -
flare.http.requestHTTP request type. 2 structs -
flare.http.request_bodyA request body that keeps arriving after the handler has started. 2 structs -
flare.http.request_builderFluent-ish per-request builder for the HTTP client. 1 struct -
flare.http.request_chunksStreaming-shape adapter for inbound request bodies. 1 struct -
flare.http.request_viewZero-copy HTTP request view. 1 struct · 1 function -
flare.http.responseHTTP response type. 2 structs · 2 functions -
flare.http.response_poolPer-workerResponsepool. 1 struct -
flare.http.response_streamStreaming-response plumbing for the normal Handler path (K1). 1 struct · 2 functions -
flare.http.routerHTTP request router with method dispatch + path parameters. 1 struct -
flare.http.routesComptime-compiled route table andComptimeRouter. 2 structs -
flare.http.serverHTTP/1.1 server with buffered reads, keep-alive, and per-connection handler callbacks. 1 struct -
flare.http.sessionSigned cookies + typed sessions. 6 structs · 3 traits · 5 functions -
flare.http.simd_parsersSIMD-friendly byte-scan primitives for the HTTP/1.1 parser hot path. 1 struct · 3 functions -
flare.http.sseServer-Sent Events (W3C SSE / RFC 9110text/event-stream). 3 structs · 3 functions -
flare.http.static_responsePre-encoded literal HTTP responses for the fastest possible fast path. 1 struct · 1 function -
flare.http.streaming_responseStreaming response with a parametric body type. 1 struct -
flare.http.streaming_serializeStreaming response serializer. 1 function -
flare.http.streaming_serverTyped streaming-handler surface. 1 struct · 1 trait · 1 function -
flare.http.structured_loggerStructured (JSON-shaped) request logger middleware. 1 struct -
flare.http.templateTiny tag-based template engine. 4 structs · 1 function -
flare.http.urlURL parser for HTTP/HTTPS URLs. 2 structs -
flare.http.wireflare.http.wire-- neutral wire-shape types shared by every HTTP wire. -
flare.http2flare.http2-- low-level HTTP/2 driver primitives (RFC 9113 + RFC 7541). -
flare.http2.clientHTTP/2 client byte driver (RFC 9113). 1 struct -
flare.http2.frameHTTP/2 frame codec (RFC 9113 §4). 4 structs · 4 functions -
flare.http2.hpackHPACK header compression (RFC 7541). 5 structs · 2 functions -
flare.http2.serverHTTP/2 server glue (RFC 9113). 1 struct · 2 functions -
flare.http2.stateHTTP/2 state machines (RFC 9113 §5). 5 structs · 2 functions -
flare.http2.stream_slabHTTP/2 per-connection stream slab. 1 struct · 1 trait -
flare.http3flare.http3— sans-I/O HTTP/3 codec primitives (RFC 9114). -
flare.http3.capsuleThe Capsule Protocol (RFC 9297 sec 3). 1 struct · 2 functions -
flare.http3.clientHTTP/3 client connection driver -- QUIC + H3 composition. 2 structs · 1 function -
flare.http3.frameHTTP/3 frame codec (RFC 9114 §7). 3 structs · 4 functions -
flare.http3.request_readerHTTP/3 request-stream reader -- sans-I/O state machine. 1 struct · 1 trait · 1 function -
flare.http3.request_writerHTTP/3 request-stream writer -- sans-I/O byte emitter. 6 functions -
flare.http3.response_readerHTTP/3 response-stream reader -- sans-I/O stateful decoder. 3 structs -
flare.http3.response_writerHTTP/3 response-stream writer -- sans-I/O byte emitter. 4 functions -
flare.http3.serverflare.http3.server-- HTTP/3 server connection driver. 3 structs · 1 function -
flare.ioBuffered I/O utilities for flare streams. -
flare.io.buf_readerBuffered reader for stream I/O. 1 struct · 1 trait -
flare.io.byte_cursorSafe, bounds-checked byte cursors. 2 structs -
flare.netRaw POSIX socket primitives — the foundation of the flare networking stack. -
flare.net.addressIP address and socket address types. 2 structs -
flare.net.errorTyped network errors for flare. 9 structs -
flare.net.socketRaw POSIX socket wrapper — the single point where flare touches the OS. 1 struct -
flare.openapiflare.openapi— OpenAPI 3.1 spec data model + JSON emitter. -
flare.openapi.from_routerDerive an :class:OpenApiSpecfrom a runtime :class:Router. 1 function -
flare.openapi.specOpenAPI 3.1 spec data model + JSON serializer. 6 structs · 1 function -
flare.preludeflare.prelude-- the everyday surface, in one import. -
flare.qpackflare.qpack-- QPACK encoder/decoder (RFC 9204). -
flare.qpack.codecQPACK encoder + decoder (RFC 9204) -- static-only. 3 functions -
flare.qpack.dynamicQPACK dynamic table + encoder/decoder stream instructions (RFC 9204). 4 structs · 15 functions -
flare.qpack.static_tableQPACK static table (RFC 9204 Appendix A). 5 functions -
flare.quicflare.quic— sans-I/O QUIC v1 codec primitives (RFC 9000). -
flare.quic.ccQUIC congestion control (RFC 9002 section 7): Reno + CUBIC (HyStart++). 3 structs · 1 trait -
flare.quic.clientflare.quic.client-- QUIC v1 client connection driver. 1 struct -
flare.quic.cryptoQUIC v1 crypto primitives (RFC 9001). 5 structs · 1 trait · 7 functions -
flare.quic.frameQUIC v1 transport-frame codec (RFC 9000 §19). 1 trait · 24 functions -
flare.quic.packetQUIC v1 packet header codec (RFC 9000 §17). 4 structs · 7 functions -
flare.quic.protectionflare.quic.protection-- QUIC v1 per-packet header + AEAD protection (RFC 9001 §5.3-5.4). 1 struct · 7 functions -
flare.quic.retryQUIC server Retry + Version Negotiation packet codecs (RFC 9000 §8.1 / §17.2.1 / §17.2.5, RFC 9001 §5.8). 8 functions -
flare.quic.serverflare.quic.server-- QUIC server reactor. 1 struct -
flare.quic.stateQUIC connection + stream state machines (RFC 9000 §3 + §13). 1 struct · 23 functions -
flare.quic.timersflare.quic.timers-- per-connection timer kinds + token encoding for the QUIC reactor. 1 struct · 3 functions -
flare.quic.transport_paramsQUIC transport-parameter codec (RFC 9000 §18 + §19.1.1). 2 structs · 7 functions -
flare.quic.varintVariable-length integer codec for QUIC (RFC 9000 §16). 1 struct · 4 functions -
flare.runtimeflare.runtime— event-loop primitives for the Stage 1 reactor. -
flare.runtime.blockingBlocking-escape hatch:block_in_pool. 1 function -
flare.runtime.buffer_poolPer-worker, size-class-bucketed buffer pool. 2 structs -
flare.runtime.date_cachePer-worker monotonic Date-header cache. 2 structs · 2 functions -
flare.runtime.eventEvent primitives for the flare reactor. 1 struct -
flare.runtime.frontendWorker-target trait for the multicore :class:Scheduler. 1 trait -
flare.runtime.handoffCross-worker connection handoff. 3 structs -
flare.runtime.io_uringio_uringbackend substrate. 2 structs · 5 functions -
flare.runtime.io_uring_abiflare.runtime.io_uring_abi-- io_uring ABI constants + byte codec. -
flare.runtime.io_uring_driverio_uringSQ/CQ ring driver. 1 struct · 2 functions -
flare.runtime.io_uring_sqeio_uringSQE encoder + CQE decoder primitives. 2 structs · 15 functions -
flare.runtime.iovecwritev(2)vectored-I/O primitive. 1 struct · 2 functions -
flare.runtime.poolTyped heap-allocator wrapper. 1 struct · 1 trait -
flare.runtime.reactorReactor: the event-loop core powering flare's single-threaded HTTP server. 1 struct -
flare.runtime.reuseportSO_REUSEPORThelpers for thread-per-core listeners. 2 functions -
flare.runtime.schedulerMulticore scheduler: 1 shared listener, N reactors, N workers. 2 structs · 1 function -
flare.runtime.scheduler_statsCross-thread stop flag and per-worker stats cell. 4 functions -
flare.runtime.timer_wheelHashed timing wheel for the flare reactor. 1 struct -
flare.runtime.uring_reactorUringReactor: io_uring-native event-loop wrapper. 1 struct · 1 function -
flare.runtime.watchdogDeadline watchdog: a background thread that flips Cancel cells on expiry. 1 struct · 3 functions -
flare.tcpBlocking TCP streams and listeners. -
flare.tcp.listenerTCP listener: a socket bound and listening for incoming connections. 1 struct · 1 function -
flare.tcp.streamTCP stream: a connected, bidirectional byte stream. 1 struct -
flare.testingflare.testing— handler + middleware testing helpers. -
flare.testing.clientIn-process test client forHandlerimplementations. 2 structs -
flare.testing.fork_serverFork-and-serve helpers for cookbook examples and integration tests. 2 functions -
flare.tlsTLS/SSL layer — wrapsTcpStreamwith OpenSSL encryption. -
flare.tls.acceptorServer-side TLS acceptor. 6 structs -
flare.tls.configTLS configuration: certificates, keys, and verification policy. 2 structs -
flare.tls.errorTLS-specific error types forflare.tls. 4 structs -
flare.tls.rustls_quicflare.tls.rustls_quic-- rustls QUIC binding surface. 7 structs -
flare.tls.streamTLS stream: encrypts a TcpStream via OpenSSL FFI. 2 structs -
flare.udpUDP datagram sockets. -
flare.udp.batchBatched UDP I/O:recvmmsg/sendmmsg+ GSO segmentation. 2 structs · 3 functions -
flare.udp.socketUDP socket: connectionless datagrams. 2 structs -
flare.udsflare.uds— Unix domain socket primitives. -
flare.uds.frame_muxMultiplexed duplex framed transport over one connection. 4 structs · 2 functions -
flare.uds.listenerAF_UNIX listener — bound + listening Unix domain socket. 1 struct · 1 function -
flare.uds.streamConnected AF_UNIX byte stream. 1 struct -
flare.utilsCross-cutting utility helpers that don't fit any other layer. -
flare.utils.dylibCanonical FFI dylib path resolver shared across :mod:flare. 3 functions -
flare.utils.posix_procPOSIX process-control helpers thin-wrapped overexternal_call. 6 functions -
flare.wsWebSocket client and server (RFC 6455). -
flare.ws.auto_clientflare.ws.auto_client-- ALPN-driven WebSocket client dispatcher. 3 structs · 1 function -
flare.ws.clientWebSocket client (RFC 6455). 3 structs -
flare.ws.client_h2WebSocket-over-HTTP/2 stream <-> frame adapter (RFC 8441). 1 struct · 1 function -
flare.ws.client_h3Client side of WebSocket over HTTP/3 (RFC 9220). 1 struct -
flare.ws.extensionsSec-WebSocket-Extensionsheader parser + emitter (RFC 6455 §9 + RFC 7692 §7). 2 structs · 3 functions -
flare.ws.frameWebSocket frame codec (RFC 6455 §5). 4 structs · 1 function -
flare.ws.permessage_deflateWebSocket permessage-deflate extension (RFC 7692). 2 structs · 2 functions -
flare.ws.protocolSans-I/O WebSocket server protocol core (RFC 6455). 2 structs -
flare.ws.serverWebSocket server: upgrades HTTP connections to WebSocket (RFC 6455). 2 structs · 1 trait · 3 functions -
flare.ws.server_h2Server-side WebSocket-over-HTTP/2 carrier (RFC 8441). 2 structs · 1 trait · 1 function -
flare.ws.server_h3Server-side WebSocket over HTTP/3 (RFC 9220). 2 structs · 1 trait · 3 functions -
flare.ws.server_reactorEvent-driven WebSocket handlers for HTTP/1.1 upgrades on the reactor. 2 structs · 1 trait · 1 function