Repository navigation
Lets a consuming project test the real router without binding a socket:
drive it with tower::ServiceExt::oneshot and get exactly what production
serves — pages, the 404, the well-known documents, the cache policy, tracing and
the body limit. Previously run was the only thing that assembled the router,
so every handler typed on the library's state was testable only over a real
port.
Testing
WebServer::into_router(shutdown)returns the finishedRouter: everything
rundoes before binding.runandinto_routershare one assembly path, so
the router a test drives cannot drift from the one that ships.- Boot validation still runs.
Okmeansrunwould have started; a site
whose asset build never ran fails here exactly as it would in a deploy. There
is no lenient test mode. - It does not require
S: AppShutdown, and it never runs the drain window or
on_shutdown.shutdown.trigger()reaches only handlers listening on
state.shutdown(). - A server without
frontendboots from any root, so a single handler can be
tested against a realWebServerStatewith no fixtures:
WebServer::with_state(..).merge(routes).into_router(Shutdown::manual()).
Configuration
WebServer::root_dir(path)sets wherehtml/,static/and
cache-buster.jsonare read from, at boot and per request. It defaults to the
working directory, so existing servers are unaffected.cargo testruns from
the crate's own directory rather than the built site; pointroot_dirat the
build output — e.g.concat!(env!("CARGO_MANIFEST_DIR"), "/../bin")from a
workspace member. It is per server, so parallel tests can use different trees.- The build-time asset pipeline still runs in the working directory.
Template
template-web-serveris now a library plus a binary, and its tests drive the
built site throughinto_router. The README's Testing withinto_router
section describes the pattern.make assetsbuildsbin/;make devandmake testboth depend on it.
No public signature changed; upgrading needs no edits.
Full Changelog: v0.2.3...v0.2.4