Struct tsukuyomi::app::builder::AppBuilder [−][src]
pub struct AppBuilder { /* fields omitted */ }A builder object for constructing an instance of App.
Methods
impl AppBuilder[src]
impl AppBuilderpub fn route(
self,
config: impl RouteConfig
) -> Self[src]
pub fn route(
self,
config: impl RouteConfig
) -> SelfAdds a route into the global scope.
Examples
use tsukuyomi::app::builder::Route; fn handler(_: &mut Input) -> Handle { // ... } fn submit(_: &mut Input) -> Handle { // ... } let app = App::builder() .route(("/", handler)) .route(("/", Method::POST, submit)) .route(|r: &mut Route| { r.uri("/submit"); r.method(Method::POST); r.handler(submit); }) .finish()?;
pub fn scope(
self,
config: impl ScopeConfig
) -> Self[src]
pub fn scope(
self,
config: impl ScopeConfig
) -> SelfCreates a new scope with the provided configuration.
Examples
use tsukuyomi::app::builder::Scope; fn get_post(_: &mut Input) -> Handle { // ... } fn add_post(_: &mut Input) -> Handle { // ... } let app = App::builder() .scope(|s: &mut Scope| { s.prefix("/api/v1"); s.route(("/posts/:id", get_post)); s.route(("/posts", "POST", add_post)); }) .finish()?;
pub fn mount(
self,
prefix: &str,
f: impl FnOnce(&mut Scope)
) -> Self[src]
pub fn mount(
self,
prefix: &str,
f: impl FnOnce(&mut Scope)
) -> SelfCreate a new scope mounted to the certain URI.
This method is a shortcut of AppBuilder::scope(Mount(prefix, f))
Examples
fn get_post(_: &mut Input) -> Handle { // ... } fn add_post(_: &mut Input) -> Handle { // ... } let app = App::builder() .mount("/api/v1", |s| { s.route(("/posts/:id", get_post)); s.route(("/posts", "POST", add_post)); }) .finish()?;
pub fn fallback_head(self, enabled: bool) -> Self[src]
pub fn fallback_head(self, enabled: bool) -> SelfSets whether the fallback to GET if the handler for HEAD is not registered is enabled or not.
The default value is true.
pub fn default_options(self, enabled: bool) -> Self[src]
pub fn default_options(self, enabled: bool) -> SelfSpecifies whether to use the default OPTIONS handlers.
If enabled, it creates the default OPTIONS handlers by collecting the registered
methods from the router and then adds them to the global scope.
pub fn error_handler(
self,
error_handler: impl ErrorHandler + Send + Sync + 'static
) -> Self[src]
pub fn error_handler(
self,
error_handler: impl ErrorHandler + Send + Sync + 'static
) -> SelfSets the instance to an error handler into this builder.
pub fn modifier(
self,
modifier: impl Modifier + Send + Sync + 'static
) -> Self[src]
pub fn modifier(
self,
modifier: impl Modifier + Send + Sync + 'static
) -> SelfRegister a Modifier into the global scope.
pub fn set<T>(self, value: T) -> Self where
T: Send + Sync + 'static, [src]
pub fn set<T>(self, value: T) -> Self where
T: Send + Sync + 'static, Sets a value of T to the global storage.
pub fn prefix(self, prefix: &str) -> Self[src]
pub fn prefix(self, prefix: &str) -> SelfSets the prefix of URIs.
pub fn finish(self) -> Result<App, Error>[src]
pub fn finish(self) -> Result<App, Error>Creates a configured App using the current settings.
Trait Implementations
impl Debug for AppBuilder[src]
impl Debug for AppBuilderAuto Trait Implementations
impl Send for AppBuilder
impl Send for AppBuilderimpl Sync for AppBuilder
impl Sync for AppBuilder