[][src]Struct roa_router::Dispatcher

pub struct Dispatcher<S>(_);

An endpoint wrapper to dispatch requests by http method.

Methods

impl<S> Dispatcher<S>[src]

pub fn get(self, endpoint: impl for<'a> Endpoint<'a, S>) -> Self[src]

Method to add or override endpoint on Method::GET.

You can use it as follow:

use roa_core::{App, Context, Result};
use roa_router::get;

async fn foo(ctx: &mut Context<()>) -> Result {
    Ok(())
}

async fn bar(ctx: &mut Context<()>) -> Result {
    Ok(())
}

let app = App::new(()).end(get(foo).get(bar));

pub fn post(self, endpoint: impl for<'a> Endpoint<'a, S>) -> Self[src]

Method to add or override endpoint on Method::POST.

You can use it as follow:

use roa_core::{App, Context, Result};
use roa_router::get;

async fn foo(ctx: &mut Context<()>) -> Result {
    Ok(())
}

async fn bar(ctx: &mut Context<()>) -> Result {
    Ok(())
}

let app = App::new(()).end(get(foo).post(bar));

pub fn put(self, endpoint: impl for<'a> Endpoint<'a, S>) -> Self[src]

Method to add or override endpoint on Method::PUT.

You can use it as follow:

use roa_core::{App, Context, Result};
use roa_router::get;

async fn foo(ctx: &mut Context<()>) -> Result {
    Ok(())
}

async fn bar(ctx: &mut Context<()>) -> Result {
    Ok(())
}

let app = App::new(()).end(get(foo).put(bar));

pub fn patch(self, endpoint: impl for<'a> Endpoint<'a, S>) -> Self[src]

Method to add or override endpoint on Method::PATCH.

You can use it as follow:

use roa_core::{App, Context, Result};
use roa_router::get;

async fn foo(ctx: &mut Context<()>) -> Result {
    Ok(())
}

async fn bar(ctx: &mut Context<()>) -> Result {
    Ok(())
}

let app = App::new(()).end(get(foo).patch(bar));

pub fn options(self, endpoint: impl for<'a> Endpoint<'a, S>) -> Self[src]

Method to add or override endpoint on Method::OPTIONS.

You can use it as follow:

use roa_core::{App, Context, Result};
use roa_router::get;

async fn foo(ctx: &mut Context<()>) -> Result {
    Ok(())
}

async fn bar(ctx: &mut Context<()>) -> Result {
    Ok(())
}

let app = App::new(()).end(get(foo).options(bar));

pub fn delete(self, endpoint: impl for<'a> Endpoint<'a, S>) -> Self[src]

Method to add or override endpoint on Method::DELETE.

You can use it as follow:

use roa_core::{App, Context, Result};
use roa_router::get;

async fn foo(ctx: &mut Context<()>) -> Result {
    Ok(())
}

async fn bar(ctx: &mut Context<()>) -> Result {
    Ok(())
}

let app = App::new(()).end(get(foo).delete(bar));

pub fn head(self, endpoint: impl for<'a> Endpoint<'a, S>) -> Self[src]

Method to add or override endpoint on Method::HEAD.

You can use it as follow:

use roa_core::{App, Context, Result};
use roa_router::get;

async fn foo(ctx: &mut Context<()>) -> Result {
    Ok(())
}

async fn bar(ctx: &mut Context<()>) -> Result {
    Ok(())
}

let app = App::new(()).end(get(foo).head(bar));

pub fn trace(self, endpoint: impl for<'a> Endpoint<'a, S>) -> Self[src]

Method to add or override endpoint on Method::TRACE.

You can use it as follow:

use roa_core::{App, Context, Result};
use roa_router::get;

async fn foo(ctx: &mut Context<()>) -> Result {
    Ok(())
}

async fn bar(ctx: &mut Context<()>) -> Result {
    Ok(())
}

let app = App::new(()).end(get(foo).trace(bar));

pub fn connect(self, endpoint: impl for<'a> Endpoint<'a, S>) -> Self[src]

Method to add or override endpoint on Method::CONNECT.

You can use it as follow:

use roa_core::{App, Context, Result};
use roa_router::get;

async fn foo(ctx: &mut Context<()>) -> Result {
    Ok(())
}

async fn bar(ctx: &mut Context<()>) -> Result {
    Ok(())
}

let app = App::new(()).end(get(foo).connect(bar));

Trait Implementations

impl<S> Default for Dispatcher<S>[src]

Empty dispatcher.

impl<'a, S> Endpoint<'a, S> for Dispatcher<S> where
    S: 'static, 
[src]

Auto Trait Implementations

impl<S> !RefUnwindSafe for Dispatcher<S>

impl<S> Send for Dispatcher<S>

impl<S> Sync for Dispatcher<S>

impl<S> Unpin for Dispatcher<S>

impl<S> !UnwindSafe for Dispatcher<S>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<'a, S, T, F> Endpoint<'a, S> for T where
    F: 'a + Future<Output = Result<(), Error>>,
    S: 'a,
    T: 'static + Send + Sync + Fn(&'a mut Context<S>) -> F, 
[src]

impl<S, T> EndpointExt<S> for T where
    T: Endpoint<'a, S>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.