dream_mock_server/router
router.gleam - Routes for mock server
Defines both streaming and non-streaming endpoints for testing Dream’s HTTP client.
Endpoints
Non-streaming:
GET /get- Returns JSON with request infoPOST /post- Echoes request body as JSONPUT /put- Echoes request body as JSONDELETE /delete- Returns success responsePOST /content-type- Echoes request Content-Type as plain textGET /json- Returns simple JSON objectGET /text- Returns plain textGET /uuid- Returns UUID-like stringGET /status/:code- Returns response with specified status codeGET /large- Returns ~1MB response (memory testing)GET /empty- Returns empty response bodyGET /slow- Returns response after 5s delay
Streaming:
GET /- Info pageGET /stream/fast- 10 chunks @ 100msGET /stream/slow- 5 chunks @ 2sGET /stream/burst- 7 chunks with variable timingGET /stream/error- 3 chunks then 500 statusGET /stream/huge- 100 chunksGET /stream/json- JSON object streamGET /stream/binary- Binary data stream
Values
pub fn create_config_router() -> router.Router(
config.MockConfigContext,
router.EmptyServices,
)
Create a router for config mode: a single catch-all route per method
that delegates to the config controller. Used when starting with
server.start_with_config(port, config).
This router intentionally contains no built-in demo endpoints. All response
behavior comes from the caller-provided MockRoute list held in context.
pub fn create_router() -> router.Router(
context.EmptyContext,
router.EmptyServices,
)
Create a router with all mock endpoints (streaming and non-streaming)
Returns a router configured with all available mock endpoints for testing HTTP clients. Use this router when starting the server programmatically.