pub struct FormConfig {
limit: usize,
err_handler: Option<Rc<dyn Fn(UrlencodedError, &HttpRequest) -> Error>>,
}
Expand description
Form
extractor configuration.
use actix_web::{post, web, App, FromRequest, Result};
use serde::Deserialize;
#[derive(Deserialize)]
struct Info {
username: String,
}
// Custom `FormConfig` is applied to App.
// Max payload size for URL encoded forms is set to 4kB.
#[post("/")]
async fn index(form: web::Form<Info>) -> Result<String> {
Ok(format!("Welcome {}!", form.username))
}
App::new()
.app_data(web::FormConfig::default().limit(4096))
.service(index);
Fields§
§limit: usize
§err_handler: Option<Rc<dyn Fn(UrlencodedError, &HttpRequest) -> Error>>
Implementations§
Source§impl FormConfig
impl FormConfig
Sourcepub fn limit(self, limit: usize) -> FormConfig
pub fn limit(self, limit: usize) -> FormConfig
Set maximum accepted payload size. By default this limit is 16kB.
Sourcepub fn error_handler<F>(self, f: F) -> FormConfig
pub fn error_handler<F>(self, f: F) -> FormConfig
Set custom error handler
Trait Implementations§
Source§impl Clone for FormConfig
impl Clone for FormConfig
Source§fn clone(&self) -> FormConfig
fn clone(&self) -> FormConfig
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Default for FormConfig
impl Default for FormConfig
Source§fn default() -> FormConfig
fn default() -> FormConfig
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for FormConfig
impl !RefUnwindSafe for FormConfig
impl !Send for FormConfig
impl !Sync for FormConfig
impl Unpin for FormConfig
impl !UnwindSafe for FormConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more