Summary
The server module's request type is documented in STANDARD.md as Request but is never registered in the typechecker. Users cannot write handler or middleware functions that accept request parameters. Additionally, server.cors() and server.use() (wired in #1580) are undocumented, and the request type should be renamed to HttpRequest for consistency with HttpResponse.
Problems
1. Request type not registered
STANDARD.md shows this handler pattern:
do home(req Request) -> HttpResponse {
return server.text(200, "Welcome!")
}
But Request is never registered via register_struct() in the typechecker. HttpResponse is registered (with fields status, body, headers), but the request type is missing entirely. Any user code referencing Request as a type will fail — meaning path params, query strings, headers, and body are all inaccessible from handlers.
This also blocks server.use() — middleware functions need to accept request/response parameters, but without the request type registered that's not possible.
2. Naming inconsistency
The response type is HttpResponse but the request type is documented as Request. These should be a uniform pair: HttpRequest and HttpResponse.
3. Undocumented functions
server.cors() and server.use() were wired in #1580 but are not listed in the STANDARD.md server module routing table.
Fix
-
Register HttpRequest as a struct in the typechecker with the following fields:
| Field |
Type |
method |
string |
path |
string |
body |
string |
query |
map[string:string] |
headers |
map[string:string] |
params |
map[string:string] |
-
Rename Request to HttpRequest in STANDARD.md docs, code examples, and handler signatures
-
Add server.cors() and server.use() to the STANDARD.md routing table:
cors — (router Router, origin string) — Enable CORS with the given origin
use — (router Router, ()middleware) — Register a middleware function
-
Update handler/middleware function signatures in codegen and typechecker to reference HttpRequest consistently
Summary
The server module's request type is documented in STANDARD.md as
Requestbut is never registered in the typechecker. Users cannot write handler or middleware functions that accept request parameters. Additionally,server.cors()andserver.use()(wired in #1580) are undocumented, and the request type should be renamed toHttpRequestfor consistency withHttpResponse.Problems
1. Request type not registered
STANDARD.md shows this handler pattern:
But
Requestis never registered viaregister_struct()in the typechecker.HttpResponseis registered (with fieldsstatus,body,headers), but the request type is missing entirely. Any user code referencingRequestas a type will fail — meaning path params, query strings, headers, and body are all inaccessible from handlers.This also blocks
server.use()— middleware functions need to accept request/response parameters, but without the request type registered that's not possible.2. Naming inconsistency
The response type is
HttpResponsebut the request type is documented asRequest. These should be a uniform pair:HttpRequestandHttpResponse.3. Undocumented functions
server.cors()andserver.use()were wired in #1580 but are not listed in the STANDARD.md server module routing table.Fix
Register
HttpRequestas a struct in the typechecker with the following fields:methodstringpathstringbodystringquerymap[string:string]headersmap[string:string]paramsmap[string:string]Rename
RequesttoHttpRequestin STANDARD.md docs, code examples, and handler signaturesAdd
server.cors()andserver.use()to the STANDARD.md routing table:cors—(router Router, origin string)— Enable CORS with the given originuse—(router Router, ()middleware)— Register a middleware functionUpdate handler/middleware function signatures in codegen and typechecker to reference
HttpRequestconsistently