Import std.net.http.work
WorkRequest
struct
Public Struct WorkRequest
A copy of a request that a work route's handler gets on another thread: what HttpRequest has but the connection, as Sendable values.
Examples
Function Report(request: WorkRequest): HttpResponse
// Blocking work, on a Workers thread, while the main thread answers other requests.
Local size = request.Param("size") ?? "small"
Return HttpResponse.Of(Body.Text("a {size} report"))
End Function
Local server = HttpServer()
server.Workers = 4
server.Work("/reports/:size", Report)
Try server.Listen("127.0.0.1", 8080)
// Serve answers requests, GET /reports/big with "a big report", until Stop.
server.Serve()-
Its method, as the client wrote it, like "GET".
-
Its target, as the client wrote it.
-
Its target's path, percent-encoded, without dot segments.
-
"HTTP/1.1" or "HTTP/1.0".
-
The client's address.
-
Its body's bytes.
-
Its headers, new Headers each time, made on the thread that asks.
-
Its query's names and values, a new QueryParams each time.
-
The body as text, its UTF-8, with U+FFFD for each byte that doesn't start well-formed UTF-8.
-
A path parameter its route bound, percent-decoded, or Null when it has none of that
name. -
Each path parameter its route bound, by name, a new Map each time.
-
A form's fields, when the body is application/x-www-form-urlencoded, or none.
Report an issue with this page or with FutureBlitz on GitHub.