diff --git a/src/extractor.rs b/src/extractor.rs index 425bc7852..5ace390dc 100644 --- a/src/extractor.rs +++ b/src/extractor.rs @@ -312,8 +312,10 @@ impl fmt::Display for Form { /// let app = App::new().resource( /// "/index.html", /// |r| { -/// r.method(http::Method::GET).with(index).limit(4096); -/// }, // <- change form extractor configuration +/// r.method(http::Method::GET) +/// // register form handler and change form extractor configuration +/// .with_config(index, |cfg| {cfg.limit(4096);}) +/// }, /// ); /// } /// ``` diff --git a/src/json.rs b/src/json.rs index d0e12c04d..0b5cb96e4 100644 --- a/src/json.rs +++ b/src/json.rs @@ -171,12 +171,13 @@ where /// fn main() { /// let app = App::new().resource("/index.html", |r| { /// r.method(http::Method::POST) -/// .with(index) -/// .limit(4096) // <- change json extractor configuration -/// .error_handler(|err, req| { // <- create custom error response -/// error::InternalError::from_response( -/// err, HttpResponse::Conflict().finish()).into() -/// }); +/// .with_config(index, |cfg| { +/// cfg.limit(4096) // <- change json extractor configuration +/// .error_handler(|err, req| { // <- create custom error response +/// error::InternalError::from_response( +/// err, HttpResponse::Conflict().finish()).into() +/// }); +/// }) /// }); /// } /// ``` @@ -326,7 +327,7 @@ mod tests { use http::header; use handler::Handler; - use with::{ExtractorConfig, With}; + use with::With; impl PartialEq for JsonPayloadError { fn eq(&self, other: &JsonPayloadError) -> bool { @@ -409,7 +410,7 @@ mod tests { #[test] fn test_with_json() { - let mut cfg = ExtractorConfig::<_, Json>::default(); + let mut cfg = JsonConfig::default(); cfg.limit(4096); let mut handler = With::new(|data: Json| data, cfg); diff --git a/src/route.rs b/src/route.rs index 7ce1104c7..4c82926e8 100644 --- a/src/route.rs +++ b/src/route.rs @@ -257,7 +257,7 @@ impl Route { /// # extern crate actix_web; /// # extern crate futures; /// #[macro_use] extern crate serde_derive; - /// use actix_web::{http, App, Error, Path}; + /// use actix_web::{http, App, Error, Form}; /// use futures::Future; /// /// #[derive(Deserialize)] @@ -318,7 +318,7 @@ impl InnerHandler { #[inline] pub fn handle(&self, req: HttpRequest) -> AsyncResult { - // reason: handler is unique per thread, handler get called from async code only + // reason: handler is unique per thread, handler get called from sync code only let h = unsafe { &mut *self.0.as_ref().get() }; h.handle(req) } diff --git a/tests/test_handlers.rs b/tests/test_handlers.rs index 57309f833..95bd5be2e 100644 --- a/tests/test_handlers.rs +++ b/tests/test_handlers.rs @@ -152,14 +152,17 @@ fn test_form_extractor() { fn test_form_extractor2() { let mut srv = test::TestServer::new(|app| { app.resource("/{username}/index.html", |r| { - r.route() - .with(|form: Form| format!("{}", form.username)) - .error_handler(|err, _| { - error::InternalError::from_response( - err, - HttpResponse::Conflict().finish(), - ).into() - }); + r.route().with_config( + |form: Form| format!("{}", form.username), + |cfg| { + cfg.error_handler(|err, _| { + error::InternalError::from_response( + err, + HttpResponse::Conflict().finish(), + ).into() + }); + }, + ); }); });