diff --git a/src/app.rs b/src/app.rs index 1cff1788e..c1c019a3c 100644 --- a/src/app.rs +++ b/src/app.rs @@ -189,9 +189,9 @@ where /// multiple resources with one route would be registered for same resource path. /// /// ```rust - /// use actix_web::{web, App, HttpResponse, extract::Path}; + /// use actix_web::{web, App, HttpResponse}; /// - /// fn index(data: Path<(String, String)>) -> &'static str { + /// fn index(data: web::Path<(String, String)>) -> &'static str { /// "Welcome!" /// } /// @@ -276,9 +276,9 @@ where /// multiple resources with one route would be registered for same resource path. /// /// ```rust - /// use actix_web::{web, App, HttpResponse, extract::Path}; + /// use actix_web::{web, App, HttpResponse}; /// - /// fn index(data: Path<(String, String)>) -> &'static str { + /// fn index(data: web::Path<(String, String)>) -> &'static str { /// "Welcome!" /// } /// diff --git a/src/extract.rs b/src/extract.rs index ac04f1c4e..c34d9df70 100644 --- a/src/extract.rs +++ b/src/extract.rs @@ -78,12 +78,12 @@ impl ExtractorConfig for () { /// ## Example /// /// ```rust -/// use actix_web::{web, http, App, extract::Path}; +/// use actix_web::{web, App}; /// /// /// extract path info from "/{username}/{count}/index.html" url /// /// {username} - deserializes to a String /// /// {count} - - deserializes to a u32 -/// fn index(info: Path<(String, u32)>) -> String { +/// fn index(info: web::Path<(String, u32)>) -> String { /// format!("Welcome {}! {}", info.0, info.1) /// } /// @@ -100,7 +100,7 @@ impl ExtractorConfig for () { /// /// ```rust /// #[macro_use] extern crate serde_derive; -/// use actix_web::{web, App, extract::Path, Error}; +/// use actix_web::{web, App, Error}; /// /// #[derive(Deserialize)] /// struct Info { @@ -108,7 +108,7 @@ impl ExtractorConfig for () { /// } /// /// /// extract `Info` from a path using serde -/// fn index(info: Path) -> Result { +/// fn index(info: web::Path) -> Result { /// Ok(format!("Welcome {}!", info.username)) /// } /// @@ -170,12 +170,12 @@ impl From for Path { /// ## Example /// /// ```rust -/// use actix_web::{web, http, App, extract::Path}; +/// use actix_web::{web, App}; /// /// /// extract path info from "/{username}/{count}/index.html" url /// /// {username} - deserializes to a String /// /// {count} - - deserializes to a u32 -/// fn index(info: Path<(String, u32)>) -> String { +/// fn index(info: web::Path<(String, u32)>) -> String { /// format!("Welcome {}! {}", info.0, info.1) /// } /// @@ -192,7 +192,7 @@ impl From for Path { /// /// ```rust /// #[macro_use] extern crate serde_derive; -/// use actix_web::{web, App, extract::Path, Error}; +/// use actix_web::{web, App, Error}; /// /// #[derive(Deserialize)] /// struct Info { @@ -200,7 +200,7 @@ impl From for Path { /// } /// /// /// extract `Info` from a path using serde -/// fn index(info: Path) -> Result { +/// fn index(info: web::Path) -> Result { /// Ok(format!("Welcome {}!", info.username)) /// } /// @@ -244,7 +244,7 @@ impl fmt::Display for Path { /// /// ```rust /// #[macro_use] extern crate serde_derive; -/// use actix_web::{web, extract, App}; +/// use actix_web::{web, App}; /// /// #[derive(Debug, Deserialize)] /// pub enum ResponseType { @@ -261,7 +261,7 @@ impl fmt::Display for Path { /// // Use `Query` extractor for query information. /// // This handler get called only if request's query contains `username` field /// // The correct request for this handler would be `/index.html?id=64&response_type=Code"` -/// fn index(info: extract::Query) -> String { +/// fn index(info: web::Query) -> String { /// format!("Authorization request for client with id={} and type={:?}!", info.id, info.response_type) /// } /// @@ -299,7 +299,7 @@ impl Query { /// /// ```rust /// #[macro_use] extern crate serde_derive; -/// use actix_web::{web, extract, App}; +/// use actix_web::{web, App}; /// /// #[derive(Debug, Deserialize)] /// pub enum ResponseType { @@ -316,7 +316,7 @@ impl Query { /// // Use `Query` extractor for query information. /// // This handler get called only if request's query contains `username` field /// // The correct request for this handler would be `/index.html?id=64&response_type=Code"` -/// fn index(info: extract::Query) -> String { +/// fn index(info: web::Query) -> String { /// format!("Authorization request for client with id={} and type={:?}!", info.id, info.response_type) /// } /// @@ -368,7 +368,7 @@ impl fmt::Display for Query { /// ```rust /// # extern crate actix_web; /// #[macro_use] extern crate serde_derive; -/// use actix_web::{web, App, extract::Form}; +/// use actix_web::{web, App}; /// /// #[derive(Deserialize)] /// struct FormData { @@ -378,7 +378,7 @@ impl fmt::Display for Query { /// /// Extract form data using serde. /// /// This handler get called only if content type is *x-www-form-urlencoded* /// /// and content of the request could be deserialized to a `FormData` struct -/// fn index(form: Form) -> String { +/// fn index(form: web::Form) -> String { /// format!("Welcome {}!", form.username) /// } /// # fn main() {} @@ -447,7 +447,7 @@ impl fmt::Display for Form { /// /// ```rust /// #[macro_use] extern crate serde_derive; -/// use actix_web::{web, extract, App, Result}; +/// use actix_web::{web, App, Result}; /// /// #[derive(Deserialize)] /// struct FormData { @@ -456,7 +456,7 @@ impl fmt::Display for Form { /// /// /// Extract form data using serde. /// /// Custom configuration is used for this handler, max payload size is 4k -/// fn index(form: extract::Form) -> Result { +/// fn index(form: web::Form) -> Result { /// Ok(format!("Welcome {}!", form.username)) /// } /// @@ -465,7 +465,7 @@ impl fmt::Display for Form { /// web::resource("/index.html") /// .route(web::get() /// // change `Form` extractor configuration -/// .config(extract::FormConfig::default().limit(4097)) +/// .config(web::FormConfig::default().limit(4097)) /// .to(index)) /// ); /// } @@ -520,7 +520,7 @@ impl Default for FormConfig { /// /// ```rust /// #[macro_use] extern crate serde_derive; -/// use actix_web::{web, extract, App}; +/// use actix_web::{web, App}; /// /// #[derive(Deserialize)] /// struct Info { @@ -528,7 +528,7 @@ impl Default for FormConfig { /// } /// /// /// deserialize `Info` from request's body -/// fn index(info: extract::Json) -> String { +/// fn index(info: web::Json) -> String { /// format!("Welcome {}!", info.username) /// } /// @@ -631,7 +631,7 @@ impl Responder for Json { /// /// ```rust /// #[macro_use] extern crate serde_derive; -/// use actix_web::{web, extract, App}; +/// use actix_web::{web, App}; /// /// #[derive(Deserialize)] /// struct Info { @@ -639,7 +639,7 @@ impl Responder for Json { /// } /// /// /// deserialize `Info` from request's body -/// fn index(info: extract::Json) -> String { +/// fn index(info: web::Json) -> String { /// format!("Welcome {}!", info.username) /// } /// @@ -679,7 +679,7 @@ where /// /// ```rust /// #[macro_use] extern crate serde_derive; -/// use actix_web::{error, extract, web, App, HttpResponse}; +/// use actix_web::{error, web, App, HttpResponse}; /// /// #[derive(Deserialize)] /// struct Info { @@ -696,7 +696,7 @@ where /// web::resource("/index.html").route( /// web::post().config( /// // change json extractor configuration -/// extract::JsonConfig::default().limit(4096) +/// web::JsonConfig::default().limit(4096) /// .error_handler(|err, req| { // <- create custom error response /// error::InternalError::from_response( /// err, HttpResponse::Conflict().finish()).into() @@ -887,7 +887,7 @@ where /// ## Example /// /// ```rust -/// use actix_web::{web, extract, App}; +/// use actix_web::{web, App}; /// /// /// extract text data from request /// fn index(text: String) -> String { @@ -898,7 +898,7 @@ where /// let app = App::new().service( /// web::resource("/index.html").route( /// web::get() -/// .config(extract::PayloadConfig::new(4096)) // <- limit size of the payload +/// .config(web::PayloadConfig::new(4096)) // <- limit size of the payload /// .to(index)) // <- register handler with extractor params /// ); /// } diff --git a/src/lib.rs b/src/lib.rs index ad4a2a866..def2abcf2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,7 @@ #![allow(clippy::type_complexity)] mod app; -pub mod extract; +mod extract; mod handler; // mod info; pub mod blocking; @@ -84,7 +84,8 @@ pub mod web { use crate::route::Route; use crate::scope::Scope; - pub use crate::extract::{Json, Path, Payload, Query}; + pub use crate::extract::{Form, Json, Path, Payload, Query}; + pub use crate::extract::{FormConfig, JsonConfig, PayloadConfig}; pub use crate::request::HttpRequest; pub use crate::state::State; diff --git a/src/resource.rs b/src/resource.rs index 157b181ef..13afff70c 100644 --- a/src/resource.rs +++ b/src/resource.rs @@ -75,9 +75,9 @@ where /// Add match guard to a resource. /// /// ```rust - /// use actix_web::{web, guard, App, HttpResponse, extract::Path}; + /// use actix_web::{web, guard, App, HttpResponse}; /// - /// fn index(data: Path<(String, String)>) -> &'static str { + /// fn index(data: web::Path<(String, String)>) -> &'static str { /// "Welcome!" /// } /// diff --git a/src/route.rs b/src/route.rs index 45bc65344..d1a8320d9 100644 --- a/src/route.rs +++ b/src/route.rs @@ -220,7 +220,7 @@ impl Route

{ /// /// ```rust /// #[macro_use] extern crate serde_derive; - /// use actix_web::{web, http, App, extract::Path}; + /// use actix_web::{web, http, App}; /// /// #[derive(Deserialize)] /// struct Info { @@ -228,7 +228,7 @@ impl Route

{ /// } /// /// /// extract path info using serde - /// fn index(info: Path) -> String { + /// fn index(info: web::Path) -> String { /// format!("Welcome {}!", info.username) /// } /// @@ -284,7 +284,7 @@ impl Route

{ /// ```rust /// # use futures::future::ok; /// #[macro_use] extern crate serde_derive; - /// use actix_web::{web, App, Error, extract::Path}; + /// use actix_web::{web, App, Error}; /// use futures::Future; /// /// #[derive(Deserialize)] @@ -293,7 +293,7 @@ impl Route

{ /// } /// /// /// extract path info using serde - /// fn index(info: Path) -> impl Future { + /// fn index(info: web::Path) -> impl Future { /// ok("Hello World!") /// } /// @@ -324,7 +324,7 @@ impl Route

{ /// for specific route. /// /// ```rust - /// use actix_web::{web, extract, App}; + /// use actix_web::{web, App}; /// /// /// extract text data from request /// fn index(body: String) -> String { @@ -336,7 +336,7 @@ impl Route

{ /// web::resource("/index.html").route( /// web::get() /// // limit size of the payload - /// .config(extract::PayloadConfig::new(4096)) + /// .config(web::PayloadConfig::new(4096)) /// // register handler /// .to(index) /// )); diff --git a/src/scope.rs b/src/scope.rs index 5580b15e4..a6358869a 100644 --- a/src/scope.rs +++ b/src/scope.rs @@ -89,9 +89,9 @@ where /// Add match guard to a scope. /// /// ```rust - /// use actix_web::{web, guard, App, HttpRequest, HttpResponse, extract::Path}; + /// use actix_web::{web, guard, App, HttpRequest, HttpResponse}; /// - /// fn index(data: Path<(String, String)>) -> &'static str { + /// fn index(data: web::Path<(String, String)>) -> &'static str { /// "Welcome!" /// } /// @@ -146,9 +146,9 @@ where /// multiple resources with one route would be registered for same resource path. /// /// ```rust - /// use actix_web::{web, App, HttpResponse, extract::Path}; + /// use actix_web::{web, App, HttpResponse}; /// - /// fn index(data: Path<(String, String)>) -> &'static str { + /// fn index(data: web::Path<(String, String)>) -> &'static str { /// "Welcome!" /// } ///