1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-06-13 02:39:32 +00:00

update new method for status filter in log middleware, add documentation

This commit is contained in:
Tglman 2023-07-26 00:14:11 +01:00
parent ca51ede874
commit 5d9e498cdf

View file

@ -128,7 +128,17 @@ impl Logger {
}
/// Set a range of status to include in the logging
pub fn status_range<R: RangeBounds<StatusCode>>(mut self, status: R) -> Self {
///
/// # Examples
/// ```
/// use actix_web::{middleware::Logger, App, http::StatusCode};
///
/// // Log only the requests with status code higher or equal to BAD_REQUEST(400)
/// let app = App::new()
/// .wrap(Logger::default().statuses(StatusCode::BAD_REQUEST..));
///
/// ```
pub fn statuses<R: RangeBounds<StatusCode>>(mut self, status: R) -> Self {
let inner = Rc::get_mut(&mut self.0).unwrap();
inner.status_range = (status.start_bound().cloned(), status.end_bound().cloned());
self