1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-11-30 18:34:36 +01:00

updated wrap and wrap fn descriptions, still requiring viable examples

This commit is contained in:
dowwie 2019-04-01 14:52:05 -04:00
parent 8800b8ef13
commit 03dfbdfcdd
2 changed files with 38 additions and 20 deletions

View File

@ -112,9 +112,12 @@ where
self self
} }
/// Registers heavyweight Application-level middleware, in the form of a /// Registers middleware, in the form of a middleware component (type),
/// re-usable middleware type, that runs during inbound and/or outbound /// that runs during inbound and/or outbound processing in the request
/// processing in the request lifecycle (request -> response). /// 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 response in some way.
/// ///
/// ```rust /// ```rust
/// use actix_service::Service; /// use actix_service::Service;
@ -171,9 +174,12 @@ where
} }
} }
/// Registers lightweight Application-level middleware, in the form of a /// Registers middleware, in the form of a closure, that runs during inbound
/// closure, that runs during inbound and/or outbound processing in the /// and/or outbound processing in the request lifecycle (request -> response),
/// request 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 response in some way.
/// ///
/// ```rust /// ```rust
/// use actix_service::Service; /// use actix_service::Service;
@ -421,9 +427,13 @@ where
self self
} }
/// Registers heavyweight Route-level middleware, in the form of a /// Registers middleware, in the form of a middleware component (type),
/// re-usable middleware type, that runs during inbound and/or outbound /// that runs during inbound and/or outbound processing in the request
/// processing in the request lifecycle (request -> response). /// lifecycle (request -> response), modifying request/response as
/// necessary, across all requests managed by the *Route*.
///
/// Use middleware when you need to read or modify *every* request or response in some way.
///
pub fn wrap<M, B1, F>( pub fn wrap<M, B1, F>(
self, self,
mw: F, mw: F,
@ -463,9 +473,13 @@ where
} }
} }
/// Registers lightweight Route-level middleware, in the form of a /// Registers middleware, in the form of a closure, that runs during inbound
/// closure, that runs during inbound and/or outbound processing in the /// and/or outbound processing in the request lifecycle (request -> response),
/// request lifecycle (request -> response). /// modifying request/response as necessary, across all requests managed by
/// the *Route*.
///
/// Use middleware when you need to read or modify *every* request or response in some way.
///
pub fn wrap_fn<B1, F, R>( pub fn wrap_fn<B1, F, R>(
self, self,
mw: F, mw: F,

View File

@ -200,11 +200,14 @@ where
self self
} }
/// Register a scope level middleware. /// Registers middleware, in the form of a middleware component (type),
/// that runs during inbound processing in the request
/// lifecycle (request -> response), modifying request as
/// necessary, across all requests managed by the *Scope*. Note that
/// Scope-level middleware is only used for inbound requests, not outbound
/// responses.
/// ///
/// This is similar to `App's` middlewares, but middleware get invoked on scope level. /// Use middleware when you need to read or modify *every* request in some way.
/// Scope level middlewares are not allowed to change response
/// type (i.e modify response's body).
pub fn wrap<M, F>( pub fn wrap<M, F>(
self, self,
mw: F, mw: F,
@ -238,10 +241,11 @@ where
} }
} }
/// Register a scope level middleware function. /// Registers middleware, in the form of a closure, that runs during inbound
/// /// processing in the request lifecycle (request -> response), modifying
/// This function accepts instance of `ServiceRequest` type and /// request as necessary, across all requests managed by the *Scope*.
/// mutable reference to the next middleware in chain. /// Note that Scope-level middleware is only used for inbound requests,
/// not outbound responses.
/// ///
/// ```rust /// ```rust
/// use actix_service::Service; /// use actix_service::Service;