From 5aeb81d7ee085ced7f044cfaddeaaf0dcf837d13 Mon Sep 17 00:00:00 2001 From: Franklin Date: Tue, 23 Aug 2022 09:44:00 -0400 Subject: [PATCH] More docs --- src/extensions/typed_response.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/extensions/typed_response.rs b/src/extensions/typed_response.rs index bb37a3d..109e8d7 100644 --- a/src/extensions/typed_response.rs +++ b/src/extensions/typed_response.rs @@ -15,7 +15,7 @@ use crate::dtos::message::MessageResource; /// if(*number > 0){ /// return TypedHttpResponse::return_standard_response(StatusCode::OK, String::from("This is my test response!")); /// } -/// TypedHttpResponse::return_empty_response(StatusCode::BAD_REQUEST); +/// TypedHttpResponse::return_empty_response(StatusCode::BAD_REQUEST) /// } /// /// ``` @@ -24,6 +24,13 @@ pub struct TypedHttpResponse { } impl TypedHttpResponse { /// Returns a response with the json struct you define inside + Status code + /// ``` + /// use actix_web::{http::StatusCode}; + /// use actix_web_utils::extensions::typed_response::TypedHttpResponse; + /// + /// TypedHttpResponse::return_standard_response(StatusCode::OK, String::from("Anything in here")); //Instead of string you can put anything here as long as it is serializable. + /// + /// ``` pub fn return_standard_response(status_code: StatusCode, body: B) -> TypedHttpResponse{ TypedHttpResponse { response: HttpResponse::with_body(StatusCode::from_u16(u16::from(status_code)).unwrap(), Some(web::Json(Ok(body))))