Struct actix_web::dev::JsonBody [−][src]
Request payload json parser that resolves to a deserialized T
value.
Returns error:
- content type is not
application/json
- content length is greater than 256k
Server example
use actix_web::{AsyncResponder, Error, HttpMessage, HttpRequest, HttpResponse}; use futures::future::Future; #[derive(Deserialize, Debug)] struct MyObj { name: String, } fn index(mut req: HttpRequest) -> Box<Future<Item = HttpResponse, Error = Error>> { req.json() // <- get JsonBody future .from_err() .and_then(|val: MyObj| { // <- deserialized value println!("==== BODY ==== {:?}", val); Ok(HttpResponse::Ok().into()) }).responder() }
Methods
impl<T: HttpMessage, U: DeserializeOwned> JsonBody<T, U>
[src]
[−]
impl<T: HttpMessage, U: DeserializeOwned> JsonBody<T, U>
pub fn new(req: &T) -> Self
[src]
[−]
pub fn new(req: &T) -> Self
Create JsonBody
for request.
pub fn limit(self, limit: usize) -> Self
[src]
[−]
pub fn limit(self, limit: usize) -> Self
Change max size of payload. By default max size is 256Kb
Trait Implementations
impl<T: HttpMessage + 'static, U: DeserializeOwned + 'static> Future for JsonBody<T, U>
[src]
[+]
impl<T: HttpMessage + 'static, U: DeserializeOwned + 'static> Future for JsonBody<T, U>