Added docs
This commit is contained in:
parent
5c2838600c
commit
d35580e71c
@ -8,13 +8,13 @@ pub struct TypedHttpResponse<B: Serialize> {
|
|||||||
pub response: HttpResponse<Option<web::Json<Result<B, Vec<MessageResource>>>>>,
|
pub response: HttpResponse<Option<web::Json<Result<B, Vec<MessageResource>>>>>,
|
||||||
}
|
}
|
||||||
impl<B: Serialize> TypedHttpResponse<B> {
|
impl<B: Serialize> TypedHttpResponse<B> {
|
||||||
// Returns a response with the json struct inside + Status code
|
/// Returns a response with the json struct inside + Status code
|
||||||
pub fn return_standard_response(status_code: StatusCode, body: B) -> TypedHttpResponse<B>{
|
pub fn return_standard_response(status_code: StatusCode, body: B) -> TypedHttpResponse<B>{
|
||||||
TypedHttpResponse {
|
TypedHttpResponse {
|
||||||
response: HttpResponse::with_body(StatusCode::from_u16(u16::from(status_code)).unwrap(), Some(web::Json(Ok(body))))
|
response: HttpResponse::with_body(StatusCode::from_u16(u16::from(status_code)).unwrap(), Some(web::Json(Ok(body))))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Returns a response with the json error list inside + Status code
|
/// Returns a response with the json error list inside + Status code
|
||||||
pub fn return_standard_error_list(status_code: StatusCode, body: Vec<MessageResource>) -> TypedHttpResponse<B>{
|
pub fn return_standard_error_list(status_code: StatusCode, body: Vec<MessageResource>) -> TypedHttpResponse<B>{
|
||||||
TypedHttpResponse {
|
TypedHttpResponse {
|
||||||
response: HttpResponse::with_body(StatusCode::from_u16(u16::from(status_code)).unwrap(), Some(web::Json(Err(body))))
|
response: HttpResponse::with_body(StatusCode::from_u16(u16::from(status_code)).unwrap(), Some(web::Json(Err(body))))
|
||||||
@ -25,7 +25,7 @@ impl<B: Serialize> TypedHttpResponse<B> {
|
|||||||
response: HttpResponse::with_body(StatusCode::from_u16(u16::from(status_code)).unwrap(), Some(web::Json(Err(vec![body]))))
|
response: HttpResponse::with_body(StatusCode::from_u16(u16::from(status_code)).unwrap(), Some(web::Json(Err(vec![body]))))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Returns an empty response with status code
|
/// Returns an empty response with status code
|
||||||
pub fn return_empty_response(status_code: StatusCode) -> TypedHttpResponse<B>{
|
pub fn return_empty_response(status_code: StatusCode) -> TypedHttpResponse<B>{
|
||||||
TypedHttpResponse {
|
TypedHttpResponse {
|
||||||
response: HttpResponse::with_body(StatusCode::from_u16(u16::from(status_code)).unwrap(), None)
|
response: HttpResponse::with_body(StatusCode::from_u16(u16::from(status_code)).unwrap(), None)
|
||||||
|
Loading…
Reference in New Issue
Block a user