mirror of
https://github.com/fafhrd91/actix-web
synced 2025-08-30 16:40:21 +02:00
Allow to construct Data instances to avoid double Arc for Send + Sync types.
This commit is contained in:
10
src/app.rs
10
src/app.rs
@@ -95,8 +95,8 @@ where
|
||||
/// web::get().to(index)));
|
||||
/// }
|
||||
/// ```
|
||||
pub fn data<S: 'static>(mut self, data: S) -> Self {
|
||||
self.data.push(Box::new(Data::new(data)));
|
||||
pub fn data<U: Into<Data<U>> + 'static>(mut self, data: U) -> Self {
|
||||
self.data.push(Box::new(data.into()));
|
||||
self
|
||||
}
|
||||
|
||||
@@ -301,14 +301,14 @@ where
|
||||
/// lifecycle (request -> response), modifying request/response as
|
||||
/// necessary, across all requests managed by the *Application*.
|
||||
///
|
||||
/// Use middleware when you need to read or modify *every* request or
|
||||
/// Use middleware when you need to read or modify *every* request or
|
||||
/// response in some way.
|
||||
///
|
||||
/// Notice that the keyword for registering middleware is `wrap`. As you
|
||||
/// Notice that the keyword for registering middleware is `wrap`. As you
|
||||
/// register middleware using `wrap` in the App builder, imagine wrapping
|
||||
/// layers around an inner App. The first middleware layer exposed to a
|
||||
/// Request is the outermost layer-- the *last* registered in
|
||||
/// the builder chain. Consequently, the *first* middleware registered
|
||||
/// the builder chain. Consequently, the *first* middleware registered
|
||||
/// in the builder chain is the *last* to execute during request processing.
|
||||
///
|
||||
/// ```rust
|
||||
|
Reference in New Issue
Block a user