Skip to content

Commit

Permalink
issue-auth rating/get.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
smart--petea committed Nov 20, 2023
1 parent df25e63 commit a42d40a
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/routes/rating/get.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
use crate::helpers::JsonResponse;
use crate::models;
use actix_web::{get, web, Responder, Result};
use serde_derive::Serialize;
use sqlx::PgPool;
use tracing::Instrument;
use crate::helpers::JsonResponse;

// workflow
// add, update, list, get(user_id), ACL,
// ACL - access to func for a user
// ACL - access to objects for a user


#[tracing::instrument(name = "Get rating.")]
#[get("/{id}")]
pub async fn get_handler(
Expand All @@ -30,14 +28,14 @@ pub async fn get_handler(
{
Ok(rating) => {
tracing::info!("rating found: {:?}", rating.id);
return JsonResponse::build().set_item(Some(rating)).ok("OK".to_string());
return JsonResponse::build().set_item(Some(rating)).ok("OK");
}
Err(sqlx::Error::RowNotFound) => {
return JsonResponse::build().err("Not Found".to_string());
return JsonResponse::build().err("Not Found");
}
Err(e) => {
tracing::error!("Failed to fetch rating, error: {:?}", e);
return JsonResponse::build().err("Internal Server Error".to_string());
return JsonResponse::build().err("Internal Server Error");
}
}
}
Expand All @@ -57,11 +55,11 @@ pub async fn default(path: web::Path<()>, pool: web::Data<PgPool>) -> Result<imp
return JsonResponse::build().set_list(rating).ok("OK".to_string());
}
Err(sqlx::Error::RowNotFound) => {
return JsonResponse::build().err("Not Found".to_string());
return JsonResponse::build().err("Not Found");
}
Err(e) => {
tracing::error!("Failed to fetch rating, error: {:?}", e);
return JsonResponse::build().err("Internal Server Error".to_string());
return JsonResponse::build().err("Internal Server Error");
}
}
}

0 comments on commit a42d40a

Please sign in to comment.