hook
ModuleHooks and routes: callbacks with declared params and injections, and the resources they are injected from.
Contents
use utopia_http::Hook;pub struct HookA callback with its declared params, injections, groups and labels.
use utopia_http::Param;pub struct ParamA param a hook or route declares: its default, validator and metadata.
use utopia_http::Resources;pub struct ResourcesA container of resources by name, falling back to a parent container.
The application's static resources are the parent of every request's context.
Debug.use utopia_http::Route;pub struct RouteA route: a hook bound to HTTP methods and a path.
A route dereferences to its Hook, so the hook's setters and getters
apply to it directly.
Deref, DerefMut.use utopia_http::Scope;pub struct Scope<'a>What a callback receives: its params and injections, the request being dispatched and its response.
use utopia_http::Check;pub enum CheckA param's validator: an instance, or a factory called with its injections.
From.use utopia_http::ParamDefault;pub enum DefaultA param's default: a value, or a factory called with its injections.
Re-exported from the crate root as ParamDefault.
From.use utopia_http::action;pub fn action<F>(f: F) -> Action where F: for<'a> Fn(Scope<'a>) -> BoxFuture<'a, Result<()>> + Send + Sync + 'static,Wraps an async callback into an Action.
pub type Action = Arc<dyn for<'a> Fn(Scope<'a>) -> BoxFuture<'a, Result<()>> + Send + Sync>A hook or route callback: takes the Scope of a call and returns a
future.
pub type BoxFuture<'a, T> = Pin<Box<dyn Future<Output = T> + Send + 'a>>A boxed, sendable future, as hook and route callbacks return.
pub type DefaultFactory = Arc<dyn Fn(&[Resource]) -> Value + Send + Sync>Builds a param's default from its injections.
pub type Resource = Arc<dyn Any + Send + Sync>An injectable resource: any shared value, read back by type with
Scope::resource.
pub type ValidatorFactory = Arc<dyn Fn(&[Resource]) -> Arc<dyn Validator> + Send + Sync>Builds a param's validator from its injections.