mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-27 17:52:56 +01:00
tweak default_service docs
This commit is contained in:
parent
a3416112a5
commit
b3e84b5c4b
12
src/app.rs
12
src/app.rs
@ -238,8 +238,12 @@ where
|
|||||||
|
|
||||||
/// Default service that is invoked when no matching resource could be found.
|
/// Default service that is invoked when no matching resource could be found.
|
||||||
///
|
///
|
||||||
/// You must use a [`Route`] as default service:
|
/// You can use a [`Route`] as default service.
|
||||||
///
|
///
|
||||||
|
/// If a default service is not registered, an empty `404 Not Found` response will be sent to
|
||||||
|
/// the client instead.
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
/// ```
|
/// ```
|
||||||
/// use actix_web::{web, App, HttpResponse};
|
/// use actix_web::{web, App, HttpResponse};
|
||||||
///
|
///
|
||||||
@ -248,10 +252,8 @@ where
|
|||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// let app = App::new()
|
/// let app = App::new()
|
||||||
/// .service(
|
/// .service(web::resource("/index.html").route(web::get().to(index)))
|
||||||
/// web::resource("/index.html").route(web::get().to(index)))
|
/// .default_service(web::to(|| HttpResponse::NotFound()));
|
||||||
/// .default_service(
|
|
||||||
/// web::route().to(|| HttpResponse::NotFound()));
|
|
||||||
/// ```
|
/// ```
|
||||||
pub fn default_service<F, U>(mut self, svc: F) -> Self
|
pub fn default_service<F, U>(mut self, svc: F) -> Self
|
||||||
where
|
where
|
||||||
|
@ -72,7 +72,7 @@ where
|
|||||||
})))
|
})))
|
||||||
});
|
});
|
||||||
|
|
||||||
// App config
|
// create App config to pass to child services
|
||||||
let mut config = AppService::new(config, default.clone());
|
let mut config = AppService::new(config, default.clone());
|
||||||
|
|
||||||
// register services
|
// register services
|
||||||
|
@ -313,10 +313,12 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Default service to be used if no matching route could be found.
|
/// Default service to be used if no matching route could be found.
|
||||||
/// You can pass a [`Route`] as default_service.
|
|
||||||
///
|
///
|
||||||
/// If no default service is specified, a `405 Method Not Allowed` response will be returned to the caller.
|
/// You can use a [`Route`] as default service.
|
||||||
/// [`Resource`] does **not** inherit the default handler specified on the parent [`App`](crate::App) or [`Scope`](crate::Scope).
|
///
|
||||||
|
/// If a default service is not registered, an empty `405 Method Not Allowed` response will be
|
||||||
|
/// sent to the client instead. Unlike [`Scope`](crate::Scope)s, a [`Resource`] does **not**
|
||||||
|
/// inherit its parent's default service.
|
||||||
pub fn default_service<F, U>(mut self, f: F) -> Self
|
pub fn default_service<F, U>(mut self, f: F) -> Self
|
||||||
where
|
where
|
||||||
F: IntoServiceFactory<U, ServiceRequest>,
|
F: IntoServiceFactory<U, ServiceRequest>,
|
||||||
|
@ -262,10 +262,10 @@ where
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Default service to be used if no matching route could be found.
|
/// Default service to be used if no matching resource could be found.
|
||||||
///
|
///
|
||||||
/// If a default service is not registered, it will fall back to the default service of
|
/// If a default service is not registered, it will fall back to the default service of
|
||||||
/// the parent [`App`](crate::App) (see [`App::default_service`](crate::App::default_service).
|
/// the parent [`App`](crate::App) (see [`App::default_service`](crate::App::default_service)).
|
||||||
pub fn default_service<F, U>(mut self, f: F) -> Self
|
pub fn default_service<F, U>(mut self, f: F) -> Self
|
||||||
where
|
where
|
||||||
F: IntoServiceFactory<U, ServiceRequest>,
|
F: IntoServiceFactory<U, ServiceRequest>,
|
||||||
|
Loading…
Reference in New Issue
Block a user