pub trait ModuleBuilderHttpExt {
// Required methods
fn controller<C: Controller + Injectable>(&mut self) -> &mut Self;
fn http_layer(&mut self, layer: GlobalLayer) -> &mut Self;
fn map_error<E: StdError + 'static>(
&mut self,
f: fn(&E) -> Option<AppError>,
) -> &mut Self;
fn error_pages(&mut self, pages: impl ErrorPages) -> &mut Self;
}Expand description
HTTP registrations on a ModuleBuilder.
Required Methods§
Sourcefn controller<C: Controller + Injectable>(&mut self) -> &mut Self
fn controller<C: Controller + Injectable>(&mut self) -> &mut Self
Registers controller C as a singleton provider of this module and
mounts its routes.
Sourcefn http_layer(&mut self, layer: GlobalLayer) -> &mut Self
fn http_layer(&mut self, layer: GlobalLayer) -> &mut Self
Adds app-wide middleware in a LayerSlot.
Only the app adds middleware that runs on every request: a module of a
plugin that is not one of the framework’s own packages stops the boot
when it calls this. A plugin ships its layer as a function, the app
adds it with one line, and a plugin’s own routes and mounts may carry
layers of their own (Endpoint::layer, Mount).
Sourcefn map_error<E: StdError + 'static>(
&mut self,
f: fn(&E) -> Option<AppError>,
) -> &mut Self
fn map_error<E: StdError + 'static>( &mut self, f: fn(&E) -> Option<AppError>, ) -> &mut Self
Maps errors of type E found in a 500 AppError’s source chain to
a specific error (e.g. a database “record not found” to 404).
The mapping answers every such error of the app. A module of a plugin that is not one of the framework’s own packages maps only the error types of the plugin’s crate: another crate’s stops the boot, and the app registers such a mapping from a module of its own.
Sourcefn error_pages(&mut self, pages: impl ErrorPages) -> &mut Self
fn error_pages(&mut self, pages: impl ErrorPages) -> &mut Self
Lets pages answer errors in another form than JSON: a page for a
browser, say. The app uses the first one contributed.
A module of a plugin that is not one of the framework’s own packages
may not call this: build_router refuses it,
which stops the boot, and the app registers such a plugin’s pages from
a module of its own.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".