Expand description
Extension / plugin-author API (handlers, bodies, route introspection, …).
Prefer this module when writing plugins: middleware helpers (with_leaked,
named), PluginMeta / PLUGIN_SDK_VERSION,
and route introspection types. Application main usually imports from the crate root
(or the sova facade) instead.
Re-exports§
pub use crate::extract::Extension;pub use crate::extract::Form;pub use crate::extract::FromRequest;pub use crate::extract::FromRequestParts;pub use crate::extract::Json as JsonExtractor;pub use crate::extract::Path;pub use crate::extract::Query;pub use crate::extract::State;pub use crate::problem::error_to_problem;pub use crate::problem::problem_response;pub use crate::problem::problem_with_errors;pub use crate::html::find_ci;pub use crate::html::inject;pub use crate::html::inject_after_open_tag;pub use crate::html::inject_before;pub use crate::html::inject_body_end;pub use crate::html::inject_head;pub use crate::html::replace_between;pub use crate::html::replace_once;pub use crate::html::HtmlAnchor;pub use crate::html::HtmlInject;
Structs§
- Build
Ctx - Context passed to
RouteValue::checkduringcrate::App::build. - Cell
- Shared
Clonevalue with change notifications (tokio::sync::watchunder the hood). - Deadline
- Absolute instant when the request budget expires (app and/or route timeout).
- Event
Bus - Sync event bus: listeners run in the dispatching task (order of registration).
- Extensions
- Per-request typed bag:
req.set(user)/req.get::<User>(). - Form
Data - Parsed form body: text fields + file uploads (urlencoded or multipart).
- Installed
Plugin - Snapshot of an installed plugin (for CLI / introspection).
- LogConfig
- Tracing install options (stdout and/or file).
- LogRecord
- Structured log event for external sinks (Elasticsearch, …).
- Matched
Meta - Route metadata bag attached to the request after a successful match.
- Matched
Meta Capture - Optional slot filled when a route matches — for root middleware that runs
before match but needs meta after
next(e.g. SEO head inject). - Matched
Route - Matched route path template (e.g.
/users/:id), set after route match. - Matched
Route Capture - Capture for root middleware: filled when a route matches (low-cardinality metrics).
- MaxBody
- Max request body size for a route / router / app scope.
- MetaMap
- Typed metadata bag for routes/routers (one value per
TypeId; last insert wins). - MwEntry
- Named middleware entry used for
crate::Router::explain. - Needs
- Declares that application state must contain
Tbefore serving. - Plugin
Meta - Human-readable plugin metadata (CLI, docs, introspection).
- Plugin
SdkVersion - Semantic version of the Plugin SDK (
major.minor.patch). - Request
Builder - Builder for test / embedded requests.
stateandextensionsstay empty —crate::App::handlefills router state. - Request
Id - Per-request correlation id (inbound
x-request-idor generated). - Request
Timeout - Per-route request timeout (inner; app-level timeout in serve still applies).
- Route
Table - Snapshot of all routes, inserted into app state at compile time.
- Slot
- One-item ownership handoff between tasks (sockets, streams, anything non-
Clone). - TypeMap
- Typed bag keyed by
TypeId(route meta, shared app state). - Upload
- One uploaded file (or any multipart part with a filename).
- Upload
Rules - Per-file constraints for
Upload::validate.
Enums§
- Bind
- Where to accept connections.
- Body
- Error
Format - Preferred error body format from an
Acceptheader value. - LogRotate
- How to rotate the log file when
LogConfig::fileis set. - Route
Entry - Registered route for introspection (OpenAPI, metrics, debug).
- SdkCompat
- Result of comparing a plugin’s declared SDK against core.
Constants§
- PLUGIN_
SDK_ VERSION - Current Plugin SDK version (author-facing surface, not crate semver).
Traits§
- Error
Response - Marker for handler errors that map via
IntoResponse(noterror_handler). - Event
- Typed application event.
- Into
Handler - Convert async functions into a
FallibleHandler. - Into
Middleware - Into
MwEntry - Convert into a named
MwEntry(explicit name vianamed, else type name). - Into
RawHandler - Route
Value - Value attached via
crate::Router::with(route, router, or app scope).
Functions§
- add_
log_ event_ hook - Append a global log sink (DevTools, Elasticsearch, …). Multiple hooks are supported.
- after
- Run
fon the response after the rest of the chain. - around
beforethen chain thenafterunder one explain name.- before
- Run
fon the request before the rest of the chain. - check_
plugin_ sdk - Compare
pluginSDK declaration againstcore(PLUGIN_SDK_VERSION). - current_
accept - Accept header captured for the current request (if any).
- ensure_
request_ id - Set
RequestIdfromx-request-idor generate one (idempotent). - ensure_
tracing - Install a default subscriber unless one is already set or
SOVA_LOG=off. - error_
response_ for_ accept - Map
ErrorusingAccept(orcurrent_acceptwhenacceptisNone). - html_
error_ page - Minimal HTML error document (no templates).
- join_
paths - logger_
skip_ path - Skip access-log lines for paths that equal or start with
prefix(e.g."/_devtools"matches/_devtools/config). - logger_
skip_ paths - Register several skip prefixes (see
logger_skip_path). - map_
html - After the handler: map buffered
text/htmlbodies withtransform. - named
- Wrap middleware with an explicit explain label (e.g.
named("auth", …)). - negotiate_
error_ format - Pick a format:
text/htmlwins over json/problem when both appear without clear exclusivity;application/problem+json/application/json→ problem; else text. - normalize_
path - parse_
bytes - Parse
"2 MiB","512 KiB","1024","1MB"→ bytes. - parse_
duration - Parse
"30s","5m","1h","500ms"→Duration. - parse_
log_ rotate - Parse rotate mode string (
size/daily/never). - request_
id - Ensure
RequestId, echox-request-id, wrap in anhttp.serverspan. - set_
log_ event_ hook - Register a global log sink hook. Prefer
add_log_event_hookwhen multiple sinks may coexist. ReturnsErr(hook)only if an older single-hook API path reserved the slot — with the multi-hook registry this always succeeds viaadd_log_event_hook. - status_
response_ for_ accept - Status-line response (router 404/405) negotiated from request Accept.
- tighten_
deadline - Keep the earlier (stricter) deadline on
req. - to_
brace_ path - Convert Express
:idto OpenAPI{id}. - wait_
shutdown - Wait until shutdown is triggered.
- with_
accept - Run
futwith the requestAcceptheader visible tocurrent_accept. - with_
leaked - Immutable plugin config that lives for the process.
Type Aliases§
- BoxError
- BoxFuture
- Fallible
Handler - Leaf handler that may return
Errorforerror_handler. - Handler
- Type-erased async handler:
Request -> Response(middleware / outer chain). - Http
Body - Boxed HTTP body used for both request streams and response streams.
- LogEvent
Hook - Callback invoked for every tracing event (after the local fmt layers).
- Middleware
- Type-erased middleware:
(Request, Next) -> Response. - RawHandler
- Escape-hatch handler: full Hyper request in, Hyper response out.
- Response
Body - Alias for
HttpBody(historical name for response streaming). - State
Map - Shared application state:
app.state(db)/req.state::<Database>().