1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-08-31 08:57:00 +02:00

refactor service registration process; unify services and resources

This commit is contained in:
Nikolay Kim
2019-03-06 15:47:15 -08:00
parent 5cde4dc479
commit fe22e83144
18 changed files with 845 additions and 779 deletions

View File

@@ -19,11 +19,10 @@ pub trait Guard {
/// use actix_web::{web, guard, App, HttpResponse};
///
/// fn main() {
/// App::new().resource("/index.html", |r|
/// r.route(
/// web::route()
/// .guard(guard::Any(guard::Get()).or(guard::Post()))
/// .to(|| HttpResponse::MethodNotAllowed()))
/// App::new().service(web::resource("/index.html").route(
/// web::route()
/// .guard(guard::Any(guard::Get()).or(guard::Post()))
/// .to(|| HttpResponse::MethodNotAllowed()))
/// );
/// }
/// ```
@@ -60,12 +59,12 @@ impl Guard for AnyGuard {
/// use actix_web::{guard, web, App, HttpResponse};
///
/// fn main() {
/// App::new().resource("/index.html", |r| {
/// r.route(web::route()
/// App::new().service(web::resource("/index.html").route(
/// web::route()
/// .guard(
/// guard::All(guard::Get()).and(guard::Header("content-type", "text/plain")))
/// .to(|| HttpResponse::MethodNotAllowed()))
/// });
/// );
/// }
/// ```
pub fn All<F: Guard + 'static>(guard: F) -> AllGuard {