From 061a875e1515950c867fa4c5e4bcebaefa99d091 Mon Sep 17 00:00:00 2001 From: Zynh0722 Date: Tue, 26 Sep 2023 17:13:46 -0700 Subject: [PATCH] remove unused example code --- src/main.rs | 39 +-------------------------------------- 1 file changed, 1 insertion(+), 38 deletions(-) diff --git a/src/main.rs b/src/main.rs index c4e2f10..11c8a1d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,13 +3,7 @@ mod axum_ructe; use axum_ructe::render; -use axum::{ - extract::State, - http::StatusCode, - response::IntoResponse, - routing::{get, post}, - Json, Router, -}; +use axum::{extract::State, response::IntoResponse, routing::get, Router}; use cm_lib::models::Shift; use diesel::result::OptionalExtension; use diesel::{ExpressionMethods, QueryDsl, SelectableHelper}; @@ -18,7 +12,6 @@ use diesel_async::{ AsyncMysqlConnection, RunQueryDsl, }; use dotenvy::dotenv; -use serde::{Deserialize, Serialize}; use std::net::SocketAddr; use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; @@ -67,7 +60,6 @@ async fn main() { let app = Router::new() .nest("/api", api::router()) .route("/", get(root)) - .route("/users", post(create_user)) .with_state(state); // run our app with hyper @@ -100,32 +92,3 @@ async fn root(State(state): State) -> impl IntoResponse { render!(templates::home_html, open_shift) } - -async fn create_user( - // this argument tells axum to parse the request body - // as JSON into a `CreateUser` type - Json(payload): Json, -) -> impl IntoResponse { - // insert your application logic here - let user = User { - id: 1337, - username: payload.username, - }; - - // this will be converted into a JSON response - // with a status code of `201 Created` - (StatusCode::CREATED, Json(user)) -} - -// the input to our `create_user` handler -#[derive(Deserialize)] -struct CreateUser { - username: String, -} - -// the output to our `create_user` handler -#[derive(Serialize)] -struct User { - id: u64, - username: String, -}