mirror of
https://github.com/actix/actix-web.git
synced 2024-11-27 03:51:10 +00:00
add more examples for extractor config
This commit is contained in:
parent
b6039b0bff
commit
4b1a471b35
1 changed files with 26 additions and 0 deletions
26
src/with.rs
26
src/with.rs
|
@ -39,6 +39,32 @@ use httpresponse::HttpResponse;
|
|||
/// );
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// Same could be donce with multiple extractors
|
||||
///
|
||||
/// ```rust
|
||||
/// # extern crate actix_web;
|
||||
/// #[macro_use] extern crate serde_derive;
|
||||
/// use actix_web::{App, Form, Path, Result, http};
|
||||
///
|
||||
/// #[derive(Deserialize)]
|
||||
/// struct FormData {
|
||||
/// username: String,
|
||||
/// }
|
||||
///
|
||||
/// fn index(data: (Path<(String,)>, Form<FormData>)) -> Result<String> {
|
||||
/// Ok(format!("Welcome {}!", data.1.username))
|
||||
/// }
|
||||
///
|
||||
/// fn main() {
|
||||
/// let app = App::new().resource(
|
||||
/// "/index.html", |r| {
|
||||
/// r.method(http::Method::GET)
|
||||
/// .with(index)
|
||||
/// .1.limit(4096);} // <- change form extractor configuration
|
||||
/// );
|
||||
/// }
|
||||
/// ```
|
||||
pub struct ExtractorConfig<S: 'static, T: FromRequest<S>> {
|
||||
cfg: Rc<UnsafeCell<T::Config>>,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue