From c273b7ac3fba82e5b740af255a0155f3e5511252 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Wed, 4 Apr 2018 08:08:31 -0700 Subject: [PATCH] update json example --- examples/json/src/main.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/examples/json/src/main.rs b/examples/json/src/main.rs index 34730366e..73863eefd 100644 --- a/examples/json/src/main.rs +++ b/examples/json/src/main.rs @@ -21,7 +21,7 @@ struct MyObj { number: i32, } -/// This handler uses `HttpRequest::json()` for loading serde json object. +/// This handler uses `HttpRequest::json()` for loading json object. fn index(req: HttpRequest) -> Box> { req.json() .from_err() // convert all errors into `Error` @@ -32,7 +32,7 @@ fn index(req: HttpRequest) -> Box> { .responder() } -/// This handler uses `With` helper for loading serde json object. +/// This handler uses json extractor fn extract_item(item: Json) -> HttpResponse { println!("model: {:?}", &item); HttpResponse::Ok().json(item.0) // <- send response @@ -40,7 +40,7 @@ fn extract_item(item: Json) -> HttpResponse { const MAX_SIZE: usize = 262_144; // max payload size is 256k -/// This handler manually load request payload and parse serde json +/// This handler manually load request payload and parse json object fn index_manual(req: HttpRequest) -> Box> { // HttpRequest is stream of Bytes objects req @@ -86,15 +86,18 @@ fn index_mjsonrust(req: HttpRequest) -> Box