http3_server
Generated by tinox doc
HTTP/3 (QUIC) server with the same route-builder API as HttpServer/Http2Server (get/post/put/patch/delete/use). Always TLS (QUIC requirement, so Http3Server::new takes a cert/key path pair), with optional 0-RTT early-data support and address validation against amplification attacks.
| Module | Version | Group |
|---|---|---|
http_server | 1.0.0 | tinox.core |
Hello server
// HTTP/3 is opt-in at build time: compile with TINOX_HTTP3=1 tinox build ...
// (without it, http3ServerCreate is unavailable and linking fails).
import tinox.core.http3_server;
class Main
{
fnc main() -> Int32
{
let server: Http3Server = Http3Server::new(8443, "cert.pem", "key.pem");
server.get("/hello", ctx => {
ctx.response.text("Hello over HTTP/3!");
});
server.listen();
return 0;
}
}
fn http3ServerCreate(port: Int64, certPath: String, keyPath: String, requireRetry: Bool, earlyDataEnabled: Bool, maxEarlyDataSize: Int64) → Int64
fn http3ServerPumpOnce(serverHandle: Int64) → Int64
fn http3RequestMethod(requestId: Int64) → String
fn http3RequestPath(requestId: Int64) → String
fn http3RequestHeaders(requestId: Int64) → Map<String, String>
fn http3RequestBody(requestId: Int64) → String
fn http3RequestWasEarlyData(requestId: Int64) → Bool
fn http3SubmitResponse(requestId: Int64, statusCode: Int64, headers: Map<String, String>, body: String) → Nothing
fn http3ReleaseRequest(requestId: Int64) → Nothing
fn http3ServerClose(serverHandle: Int64) → Nothing
class Http3Server
Fields
port | Int64 | |
certPath | String | |
keyPath | String | |
routes | List<Route> | |
middleware | List<fn(HttpContext) -> Bool> | |
serverHandle | Int64 | |
running | Bool | |
requireRetry | Bool | |
earlyDataEnabled | Bool | |
maxEarlyDataSize | Int64 |
Methods
fn new(port: Int64, certPath: String, keyPath: String) → Http3Server
fn get(path: String, handler: fn(HttpContext) -> Nothing) → Http3Server
fn post(path: String, handler: fn(HttpContext) -> Nothing) → Http3Server
fn put(path: String, handler: fn(HttpContext) -> Nothing) → Http3Server
fn patch(path: String, handler: fn(HttpContext) -> Nothing) → Http3Server
fn delete(path: String, handler: fn(HttpContext) -> Nothing) → Http3Server
fn use(mware: fn(HttpContext) -> Bool) → Http3Server
fn requireAddressValidation(v: Bool) → Http3Server
fn enableEarlyData(maxSize: Int64) → Http3Server
fn stop() → Nothing
fn listen() → Nothing
* Binds the UDP socket, completes TLS/QUIC setup, and enters the
* pump loop. Each http3ServerPumpOnce() call performs one unit of
* native work (drain ready datagrams, service ngtcp2 timer
* expiries, drive the nghttp3<->ngtcp2 write pump) and returns a
* requestId once some stream's HTTP/3 request has fully arrived,
* -1 if there was nothing to dispatch this tick, or -2 on a fatal
* socket error.
fn dispatchRequest(requestId: Int64) → Nothing
* Builds an HttpRequest/HttpContext from the C-side request slot,
* runs middleware + route matching (identical to HttpServer/
* Http2Server), calls the matched handler, then submits the
* response back through http3SubmitResponse. Mirrors
* Http2Server.dispatchStream's tail without any frame-parsing --
* nghttp3 already did that part in C.
fn runMiddleware(ctx: HttpContext) → Bool
fn matchRoute(ctx: HttpContext) → Bool