From 220c04b7b38ef39beb8cba0ef977d6c4f9e50aa4 Mon Sep 17 00:00:00 2001 From: dowwie Date: Mon, 1 Apr 2019 09:30:11 -0400 Subject: [PATCH] added docs for wrap and wrap_fn --- src/app.rs | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/src/app.rs b/src/app.rs index 9cdfc436..0c5671f7 100644 --- a/src/app.rs +++ b/src/app.rs @@ -112,7 +112,26 @@ where 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( self, 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 /// use actix_service::Service; @@ -400,7 +421,9 @@ where 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( self, 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( self, mw: F,