[−][src]Struct tide::Route
A handle to a route.
All HTTP requests are made against resources. After using Server::at
(or
Route::at
) to establish a route, the Route
type can be used to
establish endpoints for various HTTP methods at that path. Also, using
nest
, it can be used to set up a subrouter.
Methods
impl<'a, State: 'static> Route<'a, State>
[src]
pub fn at<'b>(&'b mut self, path: &str) -> Route<'b, State>
[src]
Extend the route with the given path
.
pub fn path(&self) -> &str
[src]
Get the current path.
pub fn strip_prefix(&mut self) -> &mut Self
[src]
unstable
only.Treat the current path as a prefix, and strip prefixes from requests.
This method is marked unstable as its name might change in the near future.
Endpoints will be given a path with the prefix removed.
pub fn middleware<M>(&mut self, middleware: M) -> &mut Self where
M: Middleware<State> + Debug,
[src]
M: Middleware<State> + Debug,
Apply the given middleware to the current route.
pub fn reset_middleware(&mut self) -> &mut Self
[src]
Reset the middleware chain for the current route, if any.
pub fn nest<InnerState>(&mut self, service: Server<InnerState>) -> &mut Self where
State: Send + Sync + 'static,
InnerState: Send + Sync + 'static,
[src]
State: Send + Sync + 'static,
InnerState: Send + Sync + 'static,
Nest a Server
at the current path.
pub fn serve_dir(&mut self, dir: impl AsRef<Path>) -> Result<()>
[src]
Serve a directory statically.
Each file will be streamed from disk, and a mime type will be determined based on magic bytes.
Examples
Serve the contents of the local directory ./public/images/*
from
localhost:8080/images/*
.
#[async_std::main] async fn main() -> Result<(), std::io::Error> { let mut app = tide::new(); app.at("/public/images").serve_dir("images/")?; app.listen("127.0.0.1:8080").await?; Ok(()) }
pub fn method(&mut self, method: Method, ep: impl Endpoint<State>) -> &mut Self
[src]
Add an endpoint for the given HTTP method
pub fn all(&mut self, ep: impl Endpoint<State>) -> &mut Self
[src]
Add an endpoint for all HTTP methods, as a fallback.
Routes with specific HTTP methods will be tried first.
pub fn get(&mut self, ep: impl Endpoint<State>) -> &mut Self
[src]
Add an endpoint for GET
requests
pub fn head(&mut self, ep: impl Endpoint<State>) -> &mut Self
[src]
Add an endpoint for HEAD
requests
pub fn put(&mut self, ep: impl Endpoint<State>) -> &mut Self
[src]
Add an endpoint for PUT
requests
pub fn post(&mut self, ep: impl Endpoint<State>) -> &mut Self
[src]
Add an endpoint for POST
requests
pub fn delete(&mut self, ep: impl Endpoint<State>) -> &mut Self
[src]
Add an endpoint for DELETE
requests
pub fn options(&mut self, ep: impl Endpoint<State>) -> &mut Self
[src]
Add an endpoint for OPTIONS
requests
pub fn connect(&mut self, ep: impl Endpoint<State>) -> &mut Self
[src]
Add an endpoint for CONNECT
requests
pub fn patch(&mut self, ep: impl Endpoint<State>) -> &mut Self
[src]
Add an endpoint for PATCH
requests
pub fn trace(&mut self, ep: impl Endpoint<State>) -> &mut Self
[src]
Add an endpoint for TRACE
requests
Auto Trait Implementations
impl<'a, State> !RefUnwindSafe for Route<'a, State>
impl<'a, State> Send for Route<'a, State>
impl<'a, State> Sync for Route<'a, State>
impl<'a, State> Unpin for Route<'a, State>
impl<'a, State> !UnwindSafe for Route<'a, State>
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, 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>,