pub struct ServiceConfig {
pub logger: Box<dyn Logger>,
pub handlers: Vec<Box<dyn Handler>>,
pub internal_error_handler: fn(req: &Request, ctx: &mut Context),
pub not_found_handler: fn(req: &Request, ctx: &mut Context),
}
Expand description
Configuration parameters for service Parameter E is your crate’s error type
Fields§
§logger: Box<dyn Logger>
Logger
handlers: Vec<Box<dyn Handler>>
Request handler
internal_error_handler: fn(req: &Request, ctx: &mut Context)
how to handle internal errors. This function should modify ctx.response() with results, which, for example, could include rendering a page or sending a redirect. The default implementation returns status 200 with a short text message.
not_found_handler: fn(req: &Request, ctx: &mut Context)
how to handle Not Found (404) responses. This function should modify ctx.response() with results, which, for example, could include rendering a page or sending a redirect. The default implementation returns status 404 with a short text message.
Trait Implementations§
Source§impl Default for ServiceConfig
impl Default for ServiceConfig
Source§fn default() -> ServiceConfig
fn default() -> ServiceConfig
Default construction of ServiceConfig does no logging and handles no requests.
Auto Trait Implementations§
impl Freeze for ServiceConfig
impl !RefUnwindSafe for ServiceConfig
impl !Send for ServiceConfig
impl !Sync for ServiceConfig
impl Unpin for ServiceConfig
impl !UnwindSafe for ServiceConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more