Struct hyper_routing::route::Route
source · [−]Expand description
Holds route information
Fields
method: MethodHTTP method to match
path: PathPath to match
handler: HandlerRequest handler
This should be method that accepts Hyper’s Request and Response:
ⓘ
use hyper::server::{Request, Response};
use hyper::header::{ContentLength, ContentType};
fn hello_handler(_: Request) -> Response {
let body = "Hello World";
Response::new()
.with_header(ContentLength(body.len() as u64))
.with_header(ContentType::plaintext())
.with_body(body)
}Implementations
sourceimpl Route
impl Route
pub fn options(path: &str) -> RouteBuilder
pub fn get(path: &str) -> RouteBuilder
pub fn post(path: &str) -> RouteBuilder
pub fn put(path: &str) -> RouteBuilder
pub fn delete(path: &str) -> RouteBuilder
pub fn head(path: &str) -> RouteBuilder
pub fn trace(path: &str) -> RouteBuilder
pub fn connect(path: &str) -> RouteBuilder
pub fn patch(path: &str) -> RouteBuilder
pub fn from(method: Method, path: &str) -> RouteBuilder
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Route
impl Send for Route
impl Sync for Route
impl Unpin for Route
impl UnwindSafe for Route
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more