Update documentation for App::default_service to match reality.

This commit is contained in:
Luca P 2022-01-28 09:55:30 +00:00
parent cc9ba162f7
commit a6f479a6fa
1 changed files with 3 additions and 16 deletions

View File

@ -236,9 +236,9 @@ where
self self
} }
/// Default service to be used if no matching resource could be found. /// Default service that is invoked when no matching resource could be found.
/// ///
/// It is possible to use services like `Resource`, `Route`. /// You must use a [`Route`] as default service:
/// ///
/// ``` /// ```
/// use actix_web::{web, App, HttpResponse}; /// use actix_web::{web, App, HttpResponse};
@ -253,19 +253,6 @@ where
/// .default_service( /// .default_service(
/// web::route().to(|| HttpResponse::NotFound())); /// web::route().to(|| HttpResponse::NotFound()));
/// ``` /// ```
///
/// It is also possible to use static files as default service.
///
/// ```
/// use actix_web::{web, App, HttpResponse};
///
/// let app = App::new()
/// .service(
/// web::resource("/index.html").to(|| HttpResponse::Ok()))
/// .default_service(
/// web::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
F: IntoServiceFactory<U, ServiceRequest>, F: IntoServiceFactory<U, ServiceRequest>,