1
0
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:
Nikolay Kim
2017-12-19 22:36:06 -08:00
parent c47e2ccfee
commit 7fc7d6e17a
3 changed files with 45 additions and 9 deletions

View File

@ -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());

View File

@ -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