summaryrefslogtreecommitdiffstats
path: root/src/routes/model.rs
diff options
context:
space:
mode:
authorSanto Cariotti <santo@dcariotti.me>2022-09-15 14:31:30 +0000
committerSanto Cariotti <santo@dcariotti.me>2022-09-15 14:31:30 +0000
commit3aae8ec6da9c1a1a5dffb4e8cd2ffc2560e5b9f1 (patch)
tree5c394957d980165efc174f58c56af7a1d90a472a /src/routes/model.rs
parentef8a0f433878b01cd247a009ae93d95b559d0abc (diff)
Add `JsonCreate` trait which is a Json with 201 status
Diffstat (limited to 'src/routes/model.rs')
-rw-r--r--src/routes/model.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/routes/model.rs b/src/routes/model.rs
index bc66d25..98e41dc 100644
--- a/src/routes/model.rs
+++ b/src/routes/model.rs
@@ -5,6 +5,7 @@ use crate::models::{
model::{Model, ModelCreate, ModelUpload, ModelUser},
};
use crate::pagination::Pagination;
+use crate::routes::JsonCreate;
use axum::{
extract::{ContentLengthLimit, Multipart, Path, Query},
routing::{get, post},
@@ -39,7 +40,7 @@ async fn list_models(pagination: Query<Pagination>) -> Result<Json<ModelPaginati
async fn create_model(
Json(payload): Json<ModelCreate>,
claims: Claims,
-) -> Result<Json<Model>, AppError> {
+) -> Result<JsonCreate<Model>, AppError> {
let model = Model::new(
payload.name,
payload.description,
@@ -53,7 +54,7 @@ async fn create_model(
let model_new = Model::create(model).await?;
- Ok(Json(model_new))
+ Ok(JsonCreate(model_new))
}
/// Get a model with id = `model_id`