From 3aae8ec6da9c1a1a5dffb4e8cd2ffc2560e5b9f1 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Thu, 15 Sep 2022 16:31:30 +0200 Subject: Add `JsonCreate` trait which is a Json with 201 status --- src/routes/model.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/routes/model.rs') 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) -> Result, claims: Claims, -) -> Result, AppError> { +) -> Result, 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` -- cgit v1.2.3-71-g8e6c