Skip to main content

Module rest

Module rest 

Source
Expand description

The REST harness. Behind the rest feature (on by default) so a project testing only its chat stack doesn’t compile axum and tower into its test binaries. Drive REST controllers in a test. Port of wabot-ts/src/testing/restHarness.ts.

§No port, same application

TS binds an ephemeral port and makes real fetch calls, because Express has no other way in. axum’s router is a tower::Service, so a request can be driven straight through it — no listener, no port collisions between parallel tests, no async teardown to forget.

The risk that buys is testing a different application than the one that ships: the framework wraps the router in trailing-slash normalization and the request log context, and a bare router has neither. So the harness builds its stack with rest_app — the very function run_rest_controllers calls.

Structs§

RequestBuilder
RestHarness
Mounts a router and exercises the real pipeline: routing, extractors, middlewares and guards, validation, and error mapping.
TestResponse
What came back.