Struct actix_web::dev::FormConfig
source · pub struct FormConfig<S> { /* private fields */ }
Expand description
Form extractor configuration
#[macro_use] extern crate serde_derive;
use actix_web::{http, App, Form, Result};
#[derive(Deserialize)]
struct FormData {
username: String,
}
/// extract form data using serde.
/// custom configuration is used for this handler, max payload size is 4k
fn index(form: Form<FormData>) -> Result<String> {
Ok(format!("Welcome {}!", form.username))
}
fn main() {
let app = App::new().resource(
"/index.html",
|r| {
r.method(http::Method::GET)
// register form handler and change form extractor configuration
.with_config(index, |cfg| {cfg.0.limit(4096);})
},
);
}
Implementations
sourceimpl<S> FormConfig<S>
impl<S> FormConfig<S>
sourcepub fn limit(&mut self, limit: usize) -> &mut Self
pub fn limit(&mut self, limit: usize) -> &mut Self
Change max size of payload. By default max size is 256Kb
sourcepub fn error_handler<F>(&mut self, f: F) -> &mut Selfwhere
F: Fn(UrlencodedError, &HttpRequest<S>) -> Error + 'static,
pub fn error_handler<F>(&mut self, f: F) -> &mut Selfwhere
F: Fn(UrlencodedError, &HttpRequest<S>) -> Error + 'static,
Set custom error handler
Trait Implementations
Auto Trait Implementations
impl<S> !RefUnwindSafe for FormConfig<S>
impl<S> !Send for FormConfig<S>
impl<S> !Sync for FormConfig<S>
impl<S> Unpin for FormConfig<S>
impl<S> !UnwindSafe for FormConfig<S>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more