mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-27 17:52:56 +01:00
added docs for wrap and wrap_fn
This commit is contained in:
parent
34695f4bce
commit
220c04b7b3
33
src/app.rs
33
src/app.rs
@ -112,7 +112,26 @@ where
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Register a middleware.
|
/// Registers heavyweight Application-level middleware, in the form of a
|
||||||
|
/// middleware type, that runs during inbound and/or outbound processing in the
|
||||||
|
/// request lifecycle (request -> response).
|
||||||
|
///
|
||||||
|
/// ```rust
|
||||||
|
/// use actix_service::Service;
|
||||||
|
/// # use futures::Future;
|
||||||
|
/// use actix_web::{middleware, web, App};
|
||||||
|
/// use actix_web::http::{header::CONTENT_TYPE, HeaderValue};
|
||||||
|
///
|
||||||
|
/// fn index() -> &'static str {
|
||||||
|
/// "Welcome!"
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// fn main() {
|
||||||
|
/// let app = App::new()
|
||||||
|
/// .wrap(middleware::Logger::default())
|
||||||
|
/// .route("/index.html", web::get().to(index));
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
pub fn wrap<M, B, F>(
|
pub fn wrap<M, B, F>(
|
||||||
self,
|
self,
|
||||||
mw: F,
|
mw: F,
|
||||||
@ -152,7 +171,9 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Register a middleware function.
|
/// Registers lightweight Application-level middleware, in the form of a
|
||||||
|
/// closure, that runs during inbound and/or outbound processing in the
|
||||||
|
/// request lifecycle (request -> response).
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use actix_service::Service;
|
/// use actix_service::Service;
|
||||||
@ -400,7 +421,9 @@ where
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Register a middleware.
|
/// Registers heavyweight Route-level middleware, in the form of a
|
||||||
|
/// middleware type, that runs during inbound and/or outbound processing in the
|
||||||
|
/// request lifecycle (request -> response).
|
||||||
pub fn wrap<M, B1, F>(
|
pub fn wrap<M, B1, F>(
|
||||||
self,
|
self,
|
||||||
mw: F,
|
mw: F,
|
||||||
@ -440,7 +463,9 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Register a middleware function.
|
/// Registers lightweight Route-level middleware, in the form of a
|
||||||
|
/// closure, that runs during inbound and/or outbound processing in the
|
||||||
|
/// request lifecycle (request -> response).
|
||||||
pub fn wrap_fn<B1, F, R>(
|
pub fn wrap_fn<B1, F, R>(
|
||||||
self,
|
self,
|
||||||
mw: F,
|
mw: F,
|
||||||
|
Loading…
Reference in New Issue
Block a user