From f414a491dd89976268b1fc62180e5beada0deef5 Mon Sep 17 00:00:00 2001 From: Pascal Hertleif Date: Sat, 2 Jun 2018 00:57:07 +0200 Subject: [PATCH 1/2] Fix some ResourceHandler docs Re-enables code blocks as doc tests to prevent them failing in the future. --- src/resource.rs | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/src/resource.rs b/src/resource.rs index 0920beeb8..2e2b8c6b9 100644 --- a/src/resource.rs +++ b/src/resource.rs @@ -130,8 +130,11 @@ impl ResourceHandler { /// /// This is shortcut for: /// - /// ```rust,ignore - /// Application::resource("/", |r| r.route().filter(pred::Get()).f(index) + /// ```rust + /// # extern crate actix_web; + /// # use actix_web::*; + /// # fn index(req: HttpRequest) -> HttpResponse { unimplemented!() } + /// App::new().resource("/", |r| r.route().filter(pred::Get()).f(index)); /// ``` pub fn method(&mut self, method: Method) -> &mut Route { self.routes.push(Route::default()); @@ -142,8 +145,11 @@ impl ResourceHandler { /// /// This is shortcut for: /// - /// ```rust,ignore - /// Application::resource("/", |r| r.route().h(handler) + /// ```rust + /// # extern crate actix_web; + /// # use actix_web::*; + /// # fn handler(req: HttpRequest) -> HttpResponse { unimplemented!() } + /// App::new().resource("/", |r| r.route().h(handler)); /// ``` pub fn h>(&mut self, handler: H) { self.routes.push(Route::default()); @@ -154,8 +160,11 @@ impl ResourceHandler { /// /// This is shortcut for: /// - /// ```rust,ignore - /// Application::resource("/", |r| r.route().f(index) + /// ```rust + /// # extern crate actix_web; + /// # use actix_web::*; + /// # fn index(req: HttpRequest) -> HttpResponse { unimplemented!() } + /// App::new().resource("/", |r| r.route().f(index)); /// ``` pub fn f(&mut self, handler: F) where @@ -170,8 +179,11 @@ impl ResourceHandler { /// /// This is shortcut for: /// - /// ```rust,ignore - /// Application::resource("/", |r| r.route().with(index) + /// ```rust + /// # extern crate actix_web; + /// # use actix_web::*; + /// # fn index(req: HttpRequest) -> HttpResponse { unimplemented!() } + /// App::new().resource("/", |r| r.route().with(index)); /// ``` pub fn with(&mut self, handler: F) where @@ -187,8 +199,15 @@ impl ResourceHandler { /// /// This is shortcut for: /// - /// ```rust,ignore - /// Application::resource("/", |r| r.route().with_async(index) + /// ```rust + /// # extern crate actix_web; + /// # extern crate futures; + /// # use actix_web::*; + /// # use futures::future::Future; + /// # fn index(req: HttpRequest) -> Box> { + /// # unimplemented!() + /// # } + /// App::new().resource("/", |r| r.route().with_async(index)); /// ``` pub fn with_async(&mut self, handler: F) where From d912bf8771adca12dfd70fc1def29982a29b2e1a Mon Sep 17 00:00:00 2001 From: Pascal Hertleif Date: Sat, 2 Jun 2018 00:57:24 +0200 Subject: [PATCH 2/2] Add more docs to ResourceHandler API --- src/resource.rs | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/resource.rs b/src/resource.rs index 2e2b8c6b9..af3a9e673 100644 --- a/src/resource.rs +++ b/src/resource.rs @@ -128,6 +128,14 @@ impl ResourceHandler { /// Register a new route and add method check to route. /// + /// ```rust + /// # extern crate actix_web; + /// use actix_web::*; + /// fn index(req: HttpRequest) -> HttpResponse { unimplemented!() } + /// + /// App::new().resource("/", |r| r.method(http::Method::GET).f(index)); + /// ``` + /// /// This is shortcut for: /// /// ```rust @@ -143,6 +151,14 @@ impl ResourceHandler { /// Register a new route and add handler object. /// + /// ```rust + /// # extern crate actix_web; + /// use actix_web::*; + /// fn handler(req: HttpRequest) -> HttpResponse { unimplemented!() } + /// + /// App::new().resource("/", |r| r.h(handler)); + /// ``` + /// /// This is shortcut for: /// /// ```rust @@ -158,6 +174,14 @@ impl ResourceHandler { /// Register a new route and add handler function. /// + /// ```rust + /// # extern crate actix_web; + /// use actix_web::*; + /// fn index(req: HttpRequest) -> HttpResponse { unimplemented!() } + /// + /// App::new().resource("/", |r| r.f(index)); + /// ``` + /// /// This is shortcut for: /// /// ```rust @@ -177,6 +201,14 @@ impl ResourceHandler { /// Register a new route and add handler. /// + /// ```rust + /// # extern crate actix_web; + /// use actix_web::*; + /// fn index(req: HttpRequest) -> HttpResponse { unimplemented!() } + /// + /// App::new().resource("/", |r| r.with(index)); + /// ``` + /// /// This is shortcut for: /// /// ```rust @@ -197,6 +229,19 @@ impl ResourceHandler { /// Register a new route and add async handler. /// + /// ```rust + /// # extern crate actix_web; + /// # extern crate futures; + /// use actix_web::*; + /// use futures::future::Future; + /// + /// fn index(req: HttpRequest) -> Box> { + /// unimplemented!() + /// } + /// + /// App::new().resource("/", |r| r.with_async(index)); + /// ``` + /// /// This is shortcut for: /// /// ```rust