diff --git a/README.md b/README.md index a32e4ea..86a461d 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,12 @@ Here are the available API endpoints for the service. - **Description:** Used to verify that the service is running and healthy. - **Success Response:** - **Code:** `200 OK` - - **Content:** `{"status": "ok"}` + - **Content:** `{ + "message": "health check successful", + "data": {}, + "success": true, + "error": false +}` #### Example Usage diff --git a/src/handlers/mod.rs b/src/handlers/mod.rs index 953b839..7de6496 100644 --- a/src/handlers/mod.rs +++ b/src/handlers/mod.rs @@ -1,3 +1,4 @@ // src/handlers/mod.rs pub mod health; +pub mod user; diff --git a/src/handlers/user/mod.rs b/src/handlers/user/mod.rs new file mode 100644 index 0000000..839e7ae --- /dev/null +++ b/src/handlers/user/mod.rs @@ -0,0 +1,3 @@ +// src/handlers/user/mod.rs + +pub mod user; diff --git a/src/handlers/user/user.rs b/src/handlers/user/user.rs new file mode 100644 index 0000000..f8610e9 --- /dev/null +++ b/src/handlers/user/user.rs @@ -0,0 +1,48 @@ +// src/handlers/user/user.rs + +use axum::Json; +use axum::http::StatusCode; +use axum::response::IntoResponse; +use serde_json::json; + +pub async fn user() -> impl IntoResponse { + ( + StatusCode::OK, + Json(json!( + { + "message": "health check successful", + "data": { + "id": "usr_123456789", + "username": "john_doe", + "email": "john.doe@example.com", + "first_name": "John", + "last_name": "Doe", + "role": "user", + "is_active": true, + "created_at": "2024-01-15T10:30:00Z", + "updated_at": "2024-08-15T14:20:00Z", + "profile": { + "avatar_url": "https://api.example.com/avatars/john_doe.png", + "bio": "Software developer passionate about Rust", + "location": "San Francisco, CA", + "website": "https://johndoe.dev" + }, + "preferences": { + "theme": "dark", + "language": "en", + "notifications_enabled": true, + "email_verified": true + }, + "stats": { + "total_posts": 42, + "total_comments": 156, + "total_likes": 523, + "account_age_days": 213 + } + }, + "success": true, + "error": false, + } + )), + ) +} diff --git a/src/main.rs b/src/main.rs index f0ce410..344e6f5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -44,6 +44,7 @@ async fn main() { let app = Router::new() // .nest("/health", routes::health::health::health_routes()) .nest("/health", routes::health::health::health_routes()) + .nest("/user", routes::user::user::user_routes()) .layer(TraceLayer::new_for_http()); // Run the server diff --git a/src/routes/mod.rs b/src/routes/mod.rs index e81b416..fa96a66 100644 --- a/src/routes/mod.rs +++ b/src/routes/mod.rs @@ -1,3 +1,4 @@ // src/routes/mod.rs pub mod health; +pub mod user; diff --git a/src/routes/user/mod.rs b/src/routes/user/mod.rs new file mode 100644 index 0000000..b482698 --- /dev/null +++ b/src/routes/user/mod.rs @@ -0,0 +1,3 @@ +// src/routes/user/mod.rs + +pub mod user; diff --git a/src/routes/user/user.rs b/src/routes/user/user.rs new file mode 100644 index 0000000..808a22d --- /dev/null +++ b/src/routes/user/user.rs @@ -0,0 +1,9 @@ +// src/routes/user/user.rs + +use axum::{Router, routing::get}; + +use crate::handlers::user::user::user; + +pub fn user_routes() -> Router { + Router::new().route("/", get(user)) +}