[−][src]Struct reign_router::Router
Helper to define the routing
Examples
use reign::router::Router; fn router(r: &mut Router) { r.get("foo", foo); r.scope("bar", |r| { r.post("", bar); r.delete("baz", baz); }); }
Implementations
impl<'a> Router<'a>
[src]
pub fn pipe(&mut self, pipe: Pipe<'a>)
[src]
pub fn scope<P, R>(&mut self, path: P, f: R) where
P: Into<Path<'a>>,
R: Fn(&mut Router),
[src]
P: Into<Path<'a>>,
R: Fn(&mut Router),
pub fn scope_through<P, R>(&mut self, path: P, pipes: &[&'a str], f: R) where
P: Into<Path<'a>>,
R: Fn(&mut Router),
[src]
P: Into<Path<'a>>,
R: Fn(&mut Router),
Define a scope that runs a middleware pipe
Examples
use reign::router::{Router, Pipe, middleware::Runtime}; fn router(r: &mut Router) { r.pipe(Pipe::new("common").add(Runtime::default())); r.scope_through("foo", &["common"], |r| { r.get("", foo); }); }
pub fn scope_as(&mut self, scope: Scope<'a>)
[src]
pub fn get<P, H>(&mut self, path: P, handler: H) where
P: Into<Path<'a>>,
H: Fn(&mut Request) -> HandleFuture + Send + Sync + 'static,
[src]
P: Into<Path<'a>>,
H: Fn(&mut Request) -> HandleFuture + Send + Sync + 'static,
pub fn post<P, H>(&mut self, path: P, handler: H) where
P: Into<Path<'a>>,
H: Fn(&mut Request) -> HandleFuture + Send + Sync + 'static,
[src]
P: Into<Path<'a>>,
H: Fn(&mut Request) -> HandleFuture + Send + Sync + 'static,
pub fn put<P, H>(&mut self, path: P, handler: H) where
P: Into<Path<'a>>,
H: Fn(&mut Request) -> HandleFuture + Send + Sync + 'static,
[src]
P: Into<Path<'a>>,
H: Fn(&mut Request) -> HandleFuture + Send + Sync + 'static,
pub fn patch<P, H>(&mut self, path: P, handler: H) where
P: Into<Path<'a>>,
H: Fn(&mut Request) -> HandleFuture + Send + Sync + 'static,
[src]
P: Into<Path<'a>>,
H: Fn(&mut Request) -> HandleFuture + Send + Sync + 'static,
pub fn delete<P, H>(&mut self, path: P, handler: H) where
P: Into<Path<'a>>,
H: Fn(&mut Request) -> HandleFuture + Send + Sync + 'static,
[src]
P: Into<Path<'a>>,
H: Fn(&mut Request) -> HandleFuture + Send + Sync + 'static,
pub fn head<P, H>(&mut self, path: P, handler: H) where
P: Into<Path<'a>>,
H: Fn(&mut Request) -> HandleFuture + Send + Sync + 'static,
[src]
P: Into<Path<'a>>,
H: Fn(&mut Request) -> HandleFuture + Send + Sync + 'static,
pub fn options<P, H>(&mut self, path: P, handler: H) where
P: Into<Path<'a>>,
H: Fn(&mut Request) -> HandleFuture + Send + Sync + 'static,
[src]
P: Into<Path<'a>>,
H: Fn(&mut Request) -> HandleFuture + Send + Sync + 'static,
pub fn trace<P, H>(&mut self, path: P, handler: H) where
P: Into<Path<'a>>,
H: Fn(&mut Request) -> HandleFuture + Send + Sync + 'static,
[src]
P: Into<Path<'a>>,
H: Fn(&mut Request) -> HandleFuture + Send + Sync + 'static,
pub fn connect<P, H>(&mut self, path: P, handler: H) where
P: Into<Path<'a>>,
H: Fn(&mut Request) -> HandleFuture + Send + Sync + 'static,
[src]
P: Into<Path<'a>>,
H: Fn(&mut Request) -> HandleFuture + Send + Sync + 'static,
pub fn any<P, H>(&mut self, methods: &[Method], path: P, handler: H) where
P: Into<Path<'a>>,
H: Fn(&mut Request) -> HandleFuture + Send + Sync + 'static,
[src]
P: Into<Path<'a>>,
H: Fn(&mut Request) -> HandleFuture + Send + Sync + 'static,
Any of the given methods allowed
Examples
use reign::router::{Router, hyper::Method}; fn router(r: &mut Router) { r.any(&[Method::GET], "foo", foo); }
pub fn all<P, H>(&mut self, path: P, handler: H) where
P: Into<Path<'a>>,
H: Fn(&mut Request) -> HandleFuture + Send + Sync + 'static,
[src]
P: Into<Path<'a>>,
H: Fn(&mut Request) -> HandleFuture + Send + Sync + 'static,
All methods allowed
pub fn any_with_constraint<P, C, H>(
&mut self,
methods: &[Method],
path: P,
constraint: C,
handler: H
) where
P: Into<Path<'a>>,
C: Fn(&Request) -> bool + Send + Sync + 'static,
H: Fn(&mut Request) -> HandleFuture + Send + Sync + 'static,
[src]
&mut self,
methods: &[Method],
path: P,
constraint: C,
handler: H
) where
P: Into<Path<'a>>,
C: Fn(&Request) -> bool + Send + Sync + 'static,
H: Fn(&mut Request) -> HandleFuture + Send + Sync + 'static,
Any of the given methods allowed with given constraint
Examples
use reign::router::{Router, hyper::Method}; fn router(r: &mut Router) { r.any_with_constraint(&[Method::GET], "foo", |req| { req.uri().port().is_some() || req.query("bar").is_some() }, foo); }
pub fn all_with_constraint<P, C, H>(
&mut self,
path: P,
constraint: C,
handler: H
) where
P: Into<Path<'a>>,
C: Fn(&Request) -> bool + Send + Sync + 'static,
H: Fn(&mut Request) -> HandleFuture + Send + Sync + 'static,
[src]
&mut self,
path: P,
constraint: C,
handler: H
) where
P: Into<Path<'a>>,
C: Fn(&Request) -> bool + Send + Sync + 'static,
H: Fn(&mut Request) -> HandleFuture + Send + Sync + 'static,
All methods allowed with given constraint
Trait Implementations
Auto Trait Implementations
impl<'a> !RefUnwindSafe for Router<'a>
impl<'a> Send for Router<'a>
impl<'a> Sync for Router<'a>
impl<'a> Unpin for Router<'a>
impl<'a> !UnwindSafe for Router<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Sealed<T> for T where
T: ?Sized,
T: ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,