From 03dfbdfcdd16ea7e863d76e59c742af802f2f513 Mon Sep 17 00:00:00 2001 From: dowwie Date: Mon, 1 Apr 2019 14:52:05 -0400 Subject: [PATCH] updated wrap and wrap fn descriptions, still requiring viable examples --- src/app.rs | 38 ++++++++++++++++++++++++++------------ src/scope.rs | 20 ++++++++++++-------- 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/src/app.rs b/src/app.rs index cfa6c98e..9535dac2 100644 --- a/src/app.rs +++ b/src/app.rs @@ -112,9 +112,12 @@ where self } - /// Registers heavyweight Application-level middleware, in the form of a - /// re-usable middleware type, that runs during inbound and/or outbound - /// processing in the request lifecycle (request -> response). + /// Registers middleware, in the form of a middleware component (type), + /// that runs during inbound and/or outbound processing in the 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 /// use actix_service::Service; @@ -171,9 +174,12 @@ where } } - /// 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). + /// Registers middleware, in the form of a closure, that runs during inbound + /// and/or outbound processing in the 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 /// use actix_service::Service; @@ -421,9 +427,13 @@ where self } - /// Registers heavyweight Route-level middleware, in the form of a - /// re-usable middleware type, that runs during inbound and/or outbound - /// processing in the request lifecycle (request -> response). + /// Registers middleware, in the form of a middleware component (type), + /// that runs during inbound and/or outbound processing in the 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( self, mw: F, @@ -463,9 +473,13 @@ where } } - /// 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). + /// Registers middleware, in the form of a closure, that runs during inbound + /// and/or outbound processing in the 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( self, mw: F, diff --git a/src/scope.rs b/src/scope.rs index d45609c5..3fdc4ccb 100644 --- a/src/scope.rs +++ b/src/scope.rs @@ -200,11 +200,14 @@ where 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. - /// Scope level middlewares are not allowed to change response - /// type (i.e modify response's body). + /// Use middleware when you need to read or modify *every* request in some way. pub fn wrap( self, mw: F, @@ -238,10 +241,11 @@ where } } - /// Register a scope level middleware function. - /// - /// This function accepts instance of `ServiceRequest` type and - /// mutable reference to the next middleware in chain. + /// Registers middleware, in the form of a closure, 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. /// /// ```rust /// use actix_service::Service;