summaryrefslogtreecommitdiffstats
path: root/src/routes
diff options
context:
space:
mode:
Diffstat (limited to 'src/routes')
-rw-r--r--src/routes/model.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/routes/model.rs b/src/routes/model.rs
index f85e9a7..30429f7 100644
--- a/src/routes/model.rs
+++ b/src/routes/model.rs
@@ -17,6 +17,7 @@ use serde::Serialize;
pub fn create_route() -> Router {
Router::new()
.route("/", get(list_models).post(create_model))
+ .route("/:id", get(get_model))
.route("/:id/upload", post(upload_model_file))
}
@@ -56,6 +57,14 @@ async fn create_model(
Ok(Json(model_new))
}
+/// Get a model with id = `model_id`
+async fn get_model(Path(model_id): Path<i32>) -> Result<Json<ModelUser>, AppError> {
+ match Model::find_by_id(model_id).await {
+ Ok(model) => Ok(Json(model)),
+ Err(_) => Err(AppError::NotFound("Model not found".to_string())),
+ }
+}
+
/// Upload a file for a model
async fn upload_model_file(
claims: Claims,