From c1a38b507c293ac7f6da374667828ac68121b376 Mon Sep 17 00:00:00 2001 From: Luminita Voicu Date: Mon, 9 Aug 2021 14:43:50 +0300 Subject: [PATCH] response: add `Unauthorized` status code Signed-off-by: Luminita Voicu --- src/response.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/response.rs b/src/response.rs index 344871b..147a401 100644 --- a/src/response.rs +++ b/src/response.rs @@ -22,6 +22,8 @@ pub enum StatusCode { NoContent, /// 400, Bad Request BadRequest, + /// 401, Unauthorized + Unauthorized, /// 404, Not Found NotFound, /// 405, Method Not Allowed @@ -42,6 +44,7 @@ impl StatusCode { Self::OK => b"200", Self::NoContent => b"204", Self::BadRequest => b"400", + Self::Unauthorized => b"401", Self::NotFound => b"404", Self::MethodNotAllowed => b"405", Self::InternalServerError => b"500", @@ -369,6 +372,7 @@ mod tests { assert_eq!(StatusCode::OK.raw(), b"200"); assert_eq!(StatusCode::NoContent.raw(), b"204"); assert_eq!(StatusCode::BadRequest.raw(), b"400"); + assert_eq!(StatusCode::Unauthorized.raw(), b"401"); assert_eq!(StatusCode::NotFound.raw(), b"404"); assert_eq!(StatusCode::MethodNotAllowed.raw(), b"405"); assert_eq!(StatusCode::InternalServerError.raw(), b"500");