Routes are registered before Start via AddRoute:
AddRoute(srv, "GET", "/hello", HelloHandler, NIL);
AddRoute(srv, "POST", "/echo", EchoHandler, ADR(echoCtx));
- Exact match on (method, path)
- Linear scan, first match wins
- Max 64 routes
- Default 404 if no match
PROCEDURE MyHandler(VAR req: Request; VAR resp: Response; ctx: ADDRESS);
reqcontains method, path, headers, bodyrespis pre-initialised with status 200 and empty bodyctxis the ADDRESS passed duringAddRoute
Set resp.status and append body to resp.body via ByteBuf.
Middleware runs in insertion order before the handler:
AddMiddleware(srv, SizeLimitMw, ADR(maxSize));
AddMiddleware(srv, LoggingMw, ADR(logger));
Each middleware returns BOOLEAN:
- TRUE → continue to next middleware / handler
- FALSE → short-circuit (middleware must have written the response)
| Name | Purpose | ctx parameter |
|---|---|---|
LoggingMw |
Log request method at INFO | POINTER TO Logger |
SizeLimitMw |
Reject bodies > limit (413) | POINTER TO CARDINAL |
GuardMw |
No-op pass-through | NIL |
Request → Middleware[0] → Middleware[1] → ... → Handler
↓ FALSE
Response (short-circuited)