Skip to main content

Module extend

Module extend 

Source
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::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§

BuildCtx
Context passed to RouteValue::check during crate::App::build.
Cell
Shared Clone value with change notifications (tokio::sync::watch under the hood).
Deadline
Absolute instant when the request budget expires (app and/or route timeout).
Extensions
Per-request typed bag: req.set(user) / req.get::<User>().
FormData
Parsed form body: text fields + file uploads (urlencoded or multipart).
InstalledPlugin
Snapshot of an installed plugin (for CLI / introspection).
LogConfig
Tracing install options (stdout and/or file).
LogRecord
Structured log event for external sinks (Elasticsearch, …).
MatchedMeta
Route metadata bag attached to the request after a successful match.
MatchedMetaCapture
Optional slot filled when a route matches — for root middleware that runs before match but needs meta after next (e.g. SEO head inject).
MatchedRoute
Matched route path template (e.g. /users/:id), set after route match.
MatchedRouteCapture
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 T before serving.
PluginMeta
Human-readable plugin metadata (CLI, docs, introspection).
PluginSdkVersion
Semantic version of the Plugin SDK (major.minor.patch).
RequestBuilder
Builder for test / embedded requests. state and extensions stay empty — crate::App::handle fills router state.
RequestId
Per-request correlation id (inbound x-request-id or generated).
RequestTimeout
Per-route request timeout (inner; app-level timeout in serve still applies).
RouteTable
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).
UploadRules
Per-file constraints for Upload::validate.

Enums§

Bind
Where to accept connections.
Body
LogRotate
How to rotate the log file when LogConfig::file is set.
RouteEntry
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§

ErrorResponse
Marker for handler errors that map via IntoResponse (not error_handler).
IntoHandler
Convert async functions into a FallibleHandler.
IntoMiddleware
IntoMwEntry
Convert into a named MwEntry (explicit name via named, else type name).
IntoRawHandler
RouteValue
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 f on the response after the rest of the chain.
around
before then chain then after under one explain name.
before
Run f on the request before the rest of the chain.
check_plugin_sdk
Compare plugin SDK declaration against core (PLUGIN_SDK_VERSION).
ensure_request_id
Set RequestId from x-request-id or generate one (idempotent).
ensure_tracing
Install a default subscriber unless one is already set or SOVA_LOG=off.
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/html bodies with transform.
named
Wrap middleware with an explicit explain label (e.g. named("auth", …)).
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, echo x-request-id, wrap in an http.server span.
set_log_event_hook
Register a global log sink hook. Prefer add_log_event_hook when multiple sinks may coexist. Returns Err(hook) only if an older single-hook API path reserved the slot — with the multi-hook registry this always succeeds via add_log_event_hook.
tighten_deadline
Keep the earlier (stricter) deadline on req.
to_brace_path
Convert Express :id to OpenAPI {id}.
wait_shutdown
Wait until shutdown is triggered.
with_leaked
Immutable plugin config that lives for the process.

Type Aliases§

BoxError
BoxFuture
FallibleHandler
Leaf handler that may return Error for error_handler.
Handler
Type-erased async handler: Request -> Response (middleware / outer chain).
HttpBody
Boxed HTTP body used for both request streams and response streams.
LogEventHook
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.
ResponseBody
Alias for HttpBody (historical name for response streaming).
StateMap
Shared application state: app.state(db) / req.state::<Database>().