From 0567e6fb0a2239d839eaff1c2bcad7a62c374ea7 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Wed, 20 Dec 2017 23:27:30 -0800 Subject: [PATCH] fix typos in guide --- guide/src/qs_4.md | 3 ++- guide/src/qs_4_5.md | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/guide/src/qs_4.md b/guide/src/qs_4.md index dda86e278..910e83f88 100644 --- a/guide/src/qs_4.md +++ b/guide/src/qs_4.md @@ -57,7 +57,7 @@ struct MyObj { name: &'static str, } -/// we have to convert Error into HttpResponse as well +/// Responder impl Responder for MyObj { type Item = HttpResponse; type Error = Error; @@ -72,6 +72,7 @@ impl Responder for MyObj { } } +/// Because `MyObj` implements `Responder`, it is possible to return it directly fn index(req: HttpRequest) -> MyObj { MyObj{name: "user"} } diff --git a/guide/src/qs_4_5.md b/guide/src/qs_4_5.md index cbc69654c..ef3a982ae 100644 --- a/guide/src/qs_4_5.md +++ b/guide/src/qs_4_5.md @@ -35,9 +35,9 @@ fn index(req: HttpRequest) -> io::Result { ## Custom error response -To add support for custom errors all we need to do just implement `ResponseError` trait. -`ResponseError` trait has default implementation for `error_response()` method, it -generates *500* response. +To add support for custom errors, all we need to do is just implement `ResponseError` trait +for custom error. `ResponseError` trait has default implementation +for `error_response()` method, it generates *500* response. ```rust # extern crate actix_web; @@ -50,6 +50,7 @@ struct MyError { name: &'static str } +/// Use default implementation for `error_response()` method impl error::ResponseError for MyError {} fn index(req: HttpRequest) -> Result<&'static str, MyError> { @@ -64,7 +65,7 @@ fn index(req: HttpRequest) -> Result<&'static str, MyError> { ``` In this example *index* handler will always return *500* response. But it is easy -to return different responses. +to return different responses for different type of errors. ```rust # extern crate actix_web; @@ -132,4 +133,4 @@ fn index(req: HttpRequest) -> Result<&'static str> { # } ``` -In this example *BAD REQUEST* response get generated for `MYError` error. +In this example *BAD REQUEST* response get generated for `MyError` error.