mirror of
https://github.com/actix/actix-extras.git
synced 2025-06-25 18:09:22 +02:00
update guide
This commit is contained in:
@ -92,7 +92,7 @@ impl<S: 'static> Resource<S> {
|
||||
/// This is shortcut for:
|
||||
///
|
||||
/// ```rust,ignore
|
||||
/// Resource::resource("/", |r| r.route().method(Method::GET).f(index)
|
||||
/// Resource::resource("/", |r| r.route().p(pred::Get()).f(index)
|
||||
/// ```
|
||||
pub fn method(&mut self, method: Method) -> &mut Route<S> {
|
||||
self.routes.push(Route::default());
|
||||
|
16
src/route.rs
16
src/route.rs
@ -43,6 +43,22 @@ impl<S: 'static> Route<S> {
|
||||
}
|
||||
|
||||
/// Add match predicate to route.
|
||||
///
|
||||
/// ```rust
|
||||
/// # extern crate actix_web;
|
||||
/// # use actix_web::*;
|
||||
/// # use actix_web::httpcodes::*;
|
||||
/// # fn main() {
|
||||
/// Application::new()
|
||||
/// .resource("/path", |r|
|
||||
/// r.route()
|
||||
/// .p(pred::Get())
|
||||
/// .p(pred::Header("content-type", "text/plain"))
|
||||
/// .f(|req| HTTPOk)
|
||||
/// )
|
||||
/// # .finish();
|
||||
/// # }
|
||||
/// ```
|
||||
pub fn p(&mut self, p: Box<Predicate<S>>) -> &mut Self {
|
||||
self.preds.push(p);
|
||||
self
|
||||
|
Reference in New Issue
Block a user