Struct spike::routing::Router

source ·
pub struct Router { /* private fields */ }

Implementations§

source§

impl Router

source

pub fn new() -> Self

Examples found in repository?
examples/routing.rs (line 9)
8
9
10
11
12
13
14
15
16
fn main() -> std::io::Result<()> {
    let router = Router::new()
        .route("/hello", get(hello_world).post(hello_post))
        .route("/hello", put(put_hello_world).any(any_hello))
        .route("/hi", get(|| "Hi world"))
        .route("/world", get(world));

    Server::bind("0.0.0.0:4444").serve(router)
}
source§

impl Router

source

pub fn route(self, path: &str, route: MethodRouter) -> Router

Examples found in repository?
examples/routing.rs (line 10)
8
9
10
11
12
13
14
15
16
fn main() -> std::io::Result<()> {
    let router = Router::new()
        .route("/hello", get(hello_world).post(hello_post))
        .route("/hello", put(put_hello_world).any(any_hello))
        .route("/hi", get(|| "Hi world"))
        .route("/world", get(world));

    Server::bind("0.0.0.0:4444").serve(router)
}

Trait Implementations§

source§

impl Clone for Router

source§

fn clone(&self) -> Router

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Default for Router

source§

fn default() -> Router

Returns the “default value” for a type. Read more
source§

impl Service for Router

§

type Body = Body

§

type Error = Box<dyn Error + Send + Sync>

source§

fn call(&self, req: Request<Body>) -> Result<Response<Self::Body>, Self::Error>

source§

fn should_continue(&self, _: &Request<Body>) -> StatusCode

Auto Trait Implementations§

§

impl !RefUnwindSafe for Router

§

impl Send for Router

§

impl Sync for Router

§

impl Unpin for Router

§

impl !UnwindSafe for Router

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.