Struct sharp_pencil::Module
source · [−]pub struct Module {
pub name: String,
pub root_path: String,
pub static_folder: Option<String>,
pub static_url_path: Option<String>,
pub template_folder: Option<String>,
/* private fields */
}
Expand description
Represents a module.
Fields
name: String
The name of the module.
root_path: String
The path where your module locates.
static_folder: Option<String>
The folder with static files that should be served at static_url_path
.
static_url_path: Option<String>
The url path for the static files on the web.
template_folder: Option<String>
The folder that contains the templates that should be used for the module.
Implementations
sourceimpl Module
impl Module
pub fn new(name: &str, root_path: &str) -> Module
sourcepub fn route<M: Into<Matcher>, N: AsRef<[Method]>>(
&mut self,
rule: M,
methods: N,
endpoint: &str,
view_func: ViewFunc
)
pub fn route<M: Into<Matcher>, N: AsRef<[Method]>>(
&mut self,
rule: M,
methods: N,
endpoint: &str,
view_func: ViewFunc
)
The endpoint is automatically prefixed with the module’s name.
sourcepub fn before_request<F: Fn(&mut Request<'_, '_, '_>) -> Option<PencilResult> + Send + Sync + 'static>(
&mut self,
f: F
)
pub fn before_request<F: Fn(&mut Request<'_, '_, '_>) -> Option<PencilResult> + Send + Sync + 'static>(
&mut self,
f: F
)
Before request for a module. This is only executed before each request that is handled by a view function of that module.
sourcepub fn before_app_request<F: Fn(&mut Request<'_, '_, '_>) -> Option<PencilResult> + Send + Sync + Clone + 'static>(
&mut self,
f: F
)
pub fn before_app_request<F: Fn(&mut Request<'_, '_, '_>) -> Option<PencilResult> + Send + Sync + Clone + 'static>(
&mut self,
f: F
)
Before request for the app that this module is registered on. This is executed before each request, even if outside of a module.
sourcepub fn after_request<F: Fn(&Request<'_, '_, '_>, &mut Response) + Send + Sync + 'static>(
&mut self,
f: F
)
pub fn after_request<F: Fn(&Request<'_, '_, '_>, &mut Response) + Send + Sync + 'static>(
&mut self,
f: F
)
After request for a module. This is only executed after each request that is handled by a view function of that module.
sourcepub fn after_app_request<F: Fn(&Request<'_, '_, '_>, &mut Response) + Send + Sync + Clone + 'static>(
&mut self,
f: F
)
pub fn after_app_request<F: Fn(&Request<'_, '_, '_>, &mut Response) + Send + Sync + Clone + 'static>(
&mut self,
f: F
)
After request for the app that this module is registered on. This is executed after each request, even if outside of a module.
sourcepub fn teardown_request<F: Fn(Option<&PencilError>) + Send + Sync + 'static>(
&mut self,
f: F
)
pub fn teardown_request<F: Fn(Option<&PencilError>) + Send + Sync + 'static>(
&mut self,
f: F
)
Teardown request for a module. This is only executed when tearing down each request that is handled by a view function of that module.
sourcepub fn teardown_app_request<F: Fn(Option<&PencilError>) + Send + Sync + Clone + 'static>(
&mut self,
f: F
)
pub fn teardown_app_request<F: Fn(Option<&PencilError>) + Send + Sync + Clone + 'static>(
&mut self,
f: F
)
Teardown request for the app that this module is registered on. This is executed when tearing down each request, even if outside of a module.
sourcepub fn httperrorhandler<F: Fn(HTTPError) -> PencilResult + Send + Sync + 'static>(
&mut self,
status_code: u16,
f: F
)
pub fn httperrorhandler<F: Fn(HTTPError) -> PencilResult + Send + Sync + 'static>(
&mut self,
status_code: u16,
f: F
)
Registers a http error handler that becomes active for this module only.
sourcepub fn usererrorhandler<F: Fn(UserError) -> PencilResult + Send + Sync + 'static>(
&mut self,
error_desc: &str,
f: F
)
pub fn usererrorhandler<F: Fn(UserError) -> PencilResult + Send + Sync + 'static>(
&mut self,
error_desc: &str,
f: F
)
Registers an user error handler that becomes active for this module only.
sourcepub fn app_httperrorhandler<F: Fn(HTTPError) -> PencilResult + Send + Sync + Clone + 'static>(
&mut self,
status_code: u16,
f: F
)
pub fn app_httperrorhandler<F: Fn(HTTPError) -> PencilResult + Send + Sync + Clone + 'static>(
&mut self,
status_code: u16,
f: F
)
Registers a http error handler for all requests of the application.
sourcepub fn app_usererrorhandler<F: Fn(UserError) -> PencilResult + Send + Sync + Clone + 'static>(
&mut self,
error_desc: &str,
f: F
)
pub fn app_usererrorhandler<F: Fn(UserError) -> PencilResult + Send + Sync + Clone + 'static>(
&mut self,
error_desc: &str,
f: F
)
Registers an user error handler for all requests of the application.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Module
impl Send for Module
impl Sync for Module
impl Unpin for Module
impl !UnwindSafe for Module
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more