Struct rustful::handler::tree_router::Builder [] [src]

pub struct Builder<'a, T: 'a> { /* fields omitted */ }

A builder for a TreeRouter.

Methods

impl<'a, T: Default + ApplyContext> Builder<'a, T>
[src]

Add a path to the router and keep building the resulting node.

use rustful::{Context, Response};
use rustful::handler::TreeRouter;

fn handler1(_context: Context, response: Response) {
    response.send("Hello world 1!");
}

fn handler2(_context: Context, response: Response) {
    response.send("Hello world 2!");
}

let mut router = TreeRouter::<Option<fn(Context, Response)>>::new();
router.build().path("hello/world").many(|mut node| {
    node.on_route("1", handler1);
    node.on_route("2", handler2);
});

Add a handler at the end of a path and keep building the resulting node.

use rustful::{Context, Response};
use rustful::handler::TreeRouter;

fn handler(_context: Context, response: Response) {
    response.send("Hello world!");
}

fn handler1(_context: Context, response: Response) {
    response.send("Hello world 1!");
}

fn handler2(_context: Context, response: Response) {
    response.send("Hello world 2!");
}

let mut router = TreeRouter::<Option<fn(Context, Response)>>::new();
router.build().on_path("hello/world", handler).many(|mut node| {
    node.on_route("1", handler1);
    node.on_route("2", handler2);
});

impl<'a, T> Builder<'a, T>
[src]

Perform more than one operation on this builder.

use rustful::{Context, Response};
use rustful::handler::TreeRouter;

fn handler1(_context: Context, response: Response) {
    response.send("Hello world 1!");
}

fn handler2(_context: Context, response: Response) {
    response.send("Hello world 2!");
}

let mut router = TreeRouter::<Option<fn(Context, Response)>>::new();
router.build().many(|mut node| {
    node.on_route("1", handler1);
    node.on_route("2", handler2);
});

Add a handler at the end of a route segment and keep building the resulting node.

use rustful::{Context, Response};
use rustful::handler::TreeRouter;

fn handler(_context: Context, response: Response) {
    response.send("Hello world!");
}

fn handler1(_context: Context, response: Response) {
    response.send("Hello world 1!");
}

fn handler2(_context: Context, response: Response) {
    response.send("Hello world 2!");
}

let mut router = TreeRouter::<Option<fn(Context, Response)>>::new();
router.build().on_route("hello_world", handler).many(|mut node| {
    node.on_route("1", handler1);
    node.on_route("2", handler2);
});

Try to get a node at the end of an existing path.

use rustful::{Context, Response};
use rustful::handler::TreeRouter;

fn handler(_context: Context, response: Response) {
    response.send("Hello world!");
}

let mut router = TreeRouter::<Option<fn(Context, Response)>>::new();

router.build().path("hello/world");
router.build().get_path("hello/world").expect("where did it go?!").handler(handler);

Set or replace the handler at the current node.

impl<'a: 'b, 'b, T: Build<'b>> Builder<'a, T>
[src]

Build the handler at the current node.

use rustful::{Context, Response};
use rustful::handler::{TreeRouter, MethodRouter};

fn handler(_context: Context, response: Response) {
    response.send("Hello world!");
}

let mut router = TreeRouter::<MethodRouter<fn(Context, Response)>>::new();
router.build().path("hello/world").then().on_get(handler);

impl<'a, T: Merge + ApplyContext> Builder<'a, T>
[src]

Move handlers from another router into this, overwriting conflicting handlers and properties.

Trait Implementations

Auto Trait Implementations

impl<'a, T> !Send for Builder<'a, T>

impl<'a, T> !Sync for Builder<'a, T>