Struct actix_web::dev::JsonConfig [−][src]
pub struct JsonConfig<S> { /* fields omitted */ }
Json extractor configuration
#[macro_use] extern crate serde_derive; use actix_web::{error, http, App, HttpResponse, Json, Result}; #[derive(Deserialize)] struct Info { username: String, } /// deserialize `Info` from request's body, max payload size is 4kb fn index(info: Json<Info>) -> Result<String> { Ok(format!("Welcome {}!", info.username)) } fn main() { let app = App::new().resource("/index.html", |r| { r.method(http::Method::POST) .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() }); }) }); }
Methods
impl<S> JsonConfig<S>
[src]
impl<S> JsonConfig<S>
ⓘImportant traits for &'a mut Rpub fn limit(&mut self, limit: usize) -> &mut Self
[src]
ⓘImportant traits for &'a mut R
pub fn limit(&mut self, limit: usize) -> &mut Self
Change max size of payload. By default max size is 256Kb
ⓘImportant traits for &'a mut Rpub fn error_handler<F>(&mut self, f: F) -> &mut Self where
F: Fn(JsonPayloadError, &HttpRequest<S>) -> Error + 'static,
[src]
ⓘImportant traits for &'a mut R
pub fn error_handler<F>(&mut self, f: F) -> &mut Self where
F: Fn(JsonPayloadError, &HttpRequest<S>) -> Error + 'static,
Set custom error handler
Trait Implementations
impl<S> Default for JsonConfig<S>
[src]
impl<S> Default for JsonConfig<S>
Auto Trait Implementations
impl<S> !Send for JsonConfig<S>
impl<S> !Send for JsonConfig<S>
impl<S> !Sync for JsonConfig<S>
impl<S> !Sync for JsonConfig<S>