pub struct Route {
pub method: Method,
pub path: Path,
pub handler: Handler,
}
Expand description
Holds route information
Fields§
§method: Method
HTTP method to match
path: Path
Path to match
handler: Handler
Request 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§
Source§impl 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 Freeze for Route
impl RefUnwindSafe for Route
impl Send for Route
impl Sync for Route
impl Unpin for Route
impl UnwindSafe for Route
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more