Struct actix_web::dev::Resource
[−]
[src]
pub struct Resource<S = ()> { /* fields omitted */ }
Http resource
Resource
is an entry in route table which corresponds to requested URL.
Resource in turn has at least one route. Route corresponds to handling HTTP method by calling route handler.
⚠Be careful when using this code, it's not being tested!
struct MyRoute; fn main() { let router = RoutingMap::default() .resource("/", |r| r.post::<MyRoute>()) .finish(); }
Methods
impl<S> Resource<S> where
S: 'static,
[src]
S: 'static,
fn set_name<T: ToString>(&mut self, name: T)
[src]
Set resource name
fn handler<F, R>(&mut self, method: Method, handler: F) where
F: Fn(&mut HttpRequest, Payload, &S) -> R + 'static,
R: Into<HttpResponse> + 'static,
[src]
F: Fn(&mut HttpRequest, Payload, &S) -> R + 'static,
R: Into<HttpResponse> + 'static,
Register handler for specified method.
fn async<F, R>(&mut self, method: Method, handler: F) where
F: Fn(&mut HttpRequest, Payload, &S) -> R + 'static,
R: Stream<Item = Frame, Error = ()> + 'static,
[src]
F: Fn(&mut HttpRequest, Payload, &S) -> R + 'static,
R: Stream<Item = Frame, Error = ()> + 'static,
Register async handler for specified method.
fn route_handler<H>(&mut self, method: Method, handler: H) where
H: RouteHandler<S>,
[src]
H: RouteHandler<S>,
Register handler for specified method.
fn default_handler<H>(&mut self, handler: H) where
H: RouteHandler<S>,
[src]
H: RouteHandler<S>,
Default handler is used if no matched route found.
By default HTTPMethodNotAllowed
is used.
fn get<A>(&mut self) where
A: Actor<Context = HttpContext<A>> + Route<State = S>,
[src]
A: Actor<Context = HttpContext<A>> + Route<State = S>,
Handler for GET
method.
fn post<A>(&mut self) where
A: Actor<Context = HttpContext<A>> + Route<State = S>,
[src]
A: Actor<Context = HttpContext<A>> + Route<State = S>,
Handler for POST
method.
fn put<A>(&mut self) where
A: Actor<Context = HttpContext<A>> + Route<State = S>,
[src]
A: Actor<Context = HttpContext<A>> + Route<State = S>,
Handler for PUR
method.
fn delete<A>(&mut self) where
A: Actor<Context = HttpContext<A>> + Route<State = S>,
[src]
A: Actor<Context = HttpContext<A>> + Route<State = S>,
Handler for METHOD
method.
Trait Implementations
impl<S> Default for Resource<S>
[src]
impl<S: 'static> RouteHandler<S> for Resource<S>
[src]
fn handle(&self, req: &mut HttpRequest, payload: Payload, state: Rc<S>) -> Task
[src]
Handle request
fn set_prefix(&mut self, prefix: String)
[src]
Set route prefix