Skip to main content

Crate sova_core

Crate sova_core 

Source
Expand description

Sova core — App, Router, Request, Response, middleware, server.

§Request path

acceptserver/connto_sova_requestCompiledRouter::dispatch → root middleware → matchit → route middleware → handler → IntoResponse → hyper response.

§Public surface

This crate root exports names used by applications. Plugin authors and advanced integrations use extend.

Product docs: https://s00d.github.io/sova/ (VitePress guide /guide/concepts).

Re-exports§

pub use problem::error_to_problem;
pub use problem::problem_response;
pub use problem::problem_with_errors;

Modules§

extend
Extension / plugin-author API (handlers, bodies, route introspection, …).
extract
Typed request extractors (Path, Query, Json, …) for IntoHandler.
html
HTML string helpers for plugins that mutate text/html responses.
problem
RFC 7807 Problem Details helpers (application/problem+json).

Structs§

App
Thin wrapper over Router plus server settings and lifecycle hooks.
BoundApp
App + bind target + optional programmatic shutdown.
Cell
Shared Clone value with change notifications (tokio::sync::watch under the hood).
CheckResult
Outcome of one named check from App::run_checks.
ClientAddr
Peer address stored on each request for rate-limiting etc.
ConfigDoc
Full parsed sova.toml (raw root for plugins; profile name for overlays).
EventBus
Sync event bus: listeners run in the dispatching task (order of registration).
FormData
Parsed form body: text fields + file uploads (urlencoded or multipart).
Html
HTML body (text/html; charset=utf-8).
InstalledPlugin
Snapshot of an installed plugin (for CLI / introspection).
Json
JSON body (application/json).
LogConfig
Tracing install options (stdout and/or file).
LogRecord
Structured log event for external sinks (Elasticsearch, …).
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).
NoContent
Empty 204 response.
OnUpgrade
Handle to finish an HTTP upgrade (e.g. WebSocket).
PluginMeta
Human-readable plugin metadata (CLI, docs, introspection).
PluginSdkVersion
Semantic version of the Plugin SDK (major.minor.patch).
RateLimitIdentity
Authenticated principal for rate-limit identity keys. Set by auth / passport when a user is hydrated; rate-limit falls back to IP if absent.
Redirect
HTTP redirect with explicit status.
Request
Incoming HTTP request with Express-style helpers.
RequestId
Per-request correlation id (inbound x-request-id or generated).
Response
Express-style HTTP response.
Router
Express-style router. Return from modules and app.mount("/blog", routes()).
Server
Compiled app ready to handle requests without recompiling the router.
Shutdown
Unified shutdown signal for BackgroundServices.
Slot
One-item ownership handoff between tasks (sockets, streams, anything non-Clone).
Text
Plain text (text/plain; charset=utf-8).
UpgradePermit
Holds one slot in max_upgraded_connections until dropped.
Upload
One uploaded file (or any multipart part with a filename).
UploadRules
Per-file constraints for Upload::validate.

Enums§

CheckKind
Kind of app check — readiness probes vs deploy-time audits.
Error
Framework and application errors mapped to HTTP responses.
ErrorFormat
Preferred error body format from an Accept header value.
Http
HTTP protocol mode for a bound app.
LogRotate
How to rotate the log file when LogConfig::file is set.
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§

BackgroundService
Long-running work started after on_startup, stopped after connection drain.
Event
Typed application event.
IntoResponse
Convert a value into an HTTP response.
Plugin
Single extension trait for the framework.

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).
current_accept
Accept header captured for the current request (if any).
current_request_id
Request id for the current async task (set by request_id middleware).
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.
error_response_for_accept
Map Error using Accept (or current_accept when accept is None).
html_error_page
Minimal HTML error document (no templates).
logger
Paths registered via logger_skip_path / logger_skip_paths are not logged (useful for health checks and /_devtools/*).
logger_should_skip
Whether logger (and quiet crate::request_id spans) should skip this path.
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.
negotiate_error_format
Pick a format: text/html wins over json/problem when both appear without clear exclusivity; application/problem+json / application/json → problem; else text.
parse_log_rotate
Parse rotate mode string (size / daily / never).
referer_or
Referer header value, or fallback when absent/empty.
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.
status_response_for_accept
Status-line response (router 404/405) negotiated from request Accept.
with_accept
Run fut with the request Accept header visible to current_accept.
with_state
Middleware with owned state — hides the Arc::clone dance.

Type Aliases§

LogEventHook
Callback invoked for every tracing event (after the local fmt layers).
Next
Call the rest of the middleware / handler chain.
Result