Struct tsukuyomi::app::builder::AppBuilder[][src]

pub struct AppBuilder { /* fields omitted */ }

A builder object for constructing an instance of App.

Methods

impl AppBuilder
[src]

Adds 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()?;

Creates 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()?;

Create 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()?;

Sets whether the fallback to GET if the handler for HEAD is not registered is enabled or not.

The default value is true.

Specifies 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.

Sets the instance to an error handler into this builder.

Register a Modifier into the global scope.

Sets a value of T to the global storage.

Sets the prefix of URIs.

Creates a configured App using the current settings.

Trait Implementations

impl Debug for AppBuilder
[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl Send for AppBuilder

impl Sync for AppBuilder