Struct actix_web::dev::ResourceHandler
[−]
[src]
pub struct ResourceHandler<S = ()> { /* fields omitted */ }
Resource is an entry in route table which corresponds to requested URL.
Resource in turn has at least one route.
Route consists of an object that implements Handler
trait (handler)
and list of predicates (objects that implement Predicate
trait).
Route uses builder-like pattern for configuration.
During request handling, resource object iterate through all routes
and check all predicates for specific route, if request matches all
predicates route route considered matched and route handler get called.
use actix_web::{App, HttpResponse, http}; fn main() { let app = App::new() .resource( "/", |r| r.method(http::Method::GET).f(|r| HttpResponse::Ok())) .finish(); }
Methods
impl<S> ResourceHandler<S>
[src]
impl<S: 'static> ResourceHandler<S>
[src]
pub fn route(&mut self) -> &mut Route<S>
[src]
Register a new route and return mutable reference to Route object. Route is used for route configuration, i.e. adding predicates, setting up handler.
use actix_web::*; fn main() { let app = App::new() .resource( "/", |r| r.route() .filter(pred::Any(pred::Get()).or(pred::Put())) .filter(pred::Header("Content-Type", "text/plain")) .f(|r| HttpResponse::Ok())) .finish(); }
pub fn get(&mut self) -> &mut Route<S>
[src]
Register a new GET
route.
pub fn post(&mut self) -> &mut Route<S>
[src]
Register a new POST
route.
pub fn put(&mut self) -> &mut Route<S>
[src]
Register a new PUT
route.
pub fn delete(&mut self) -> &mut Route<S>
[src]
Register a new DELETE
route.
pub fn head(&mut self) -> &mut Route<S>
[src]
Register a new HEAD
route.
pub fn method(&mut self, method: Method) -> &mut Route<S>
[src]
Register a new route and add method check to route.
This is shortcut for:
Application::resource("/", |r| r.route().filter(pred::Get()).f(index)
pub fn h<H: Handler<S>>(&mut self, handler: H)
[src]
Register a new route and add handler object.
This is shortcut for:
Application::resource("/", |r| r.route().h(handler)
pub fn f<F, R>(&mut self, handler: F) where
F: Fn(HttpRequest<S>) -> R + 'static,
R: Responder + 'static,
[src]
F: Fn(HttpRequest<S>) -> R + 'static,
R: Responder + 'static,
Register a new route and add handler function.
This is shortcut for:
Application::resource("/", |r| r.route().f(index)
pub fn with<T, F, R>(&mut self, handler: F) where
F: Fn(T) -> R + 'static,
R: Responder + 'static,
T: FromRequest<S> + 'static,
[src]
F: Fn(T) -> R + 'static,
R: Responder + 'static,
T: FromRequest<S> + 'static,
Register a new route and add handler.
This is shortcut for:
Application::resource("/", |r| r.route().with(index)
pub fn middleware<M: Middleware<S>>(&mut self, mw: M)
[src]
Register a resource middleware
This is similar to App's
middlewares, but
middlewares get invoked on resource level.