From 33d2621cf3f45fa79d93e1800fa688a47b0ad127 Mon Sep 17 00:00:00 2001 From: Mats Rauhala Date: Tue, 6 Oct 2026 08:24:08 +0300 Subject: [PATCH] 201 on create --- src/api/users.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/api/users.rs b/src/api/users.rs index 4bd898b..7712ea1 100644 --- a/src/api/users.rs +++ b/src/api/users.rs @@ -1,4 +1,4 @@ -use axum::{Json, Router, extract::State, routing}; +use axum::{Json, Router, extract::State, http::StatusCode, routing}; use secrecy::SecretString; use serde::{Deserialize, Serialize}; use tracing::instrument; @@ -27,12 +27,12 @@ pub fn users_routes() -> Router { } #[instrument(skip_all)] -#[axum::debug_handler] -pub async fn create_user(State(st) : State, Json(create_user): Json) -> Result, AppError> { +pub async fn create_user(State(st) : State, Json(create_user): Json) -> Result<(StatusCode, axum::Json), AppError> { + tracing::info!("Creating user {:?}", create_user.username); let username = st.users .create_user(&create_user.username, SecretString::from(create_user.password)) .await?; - Ok(Json(UserCreated{username})) + Ok((StatusCode::CREATED, Json(UserCreated{username}))) } #[derive(Serialize, Debug)]