remove unused example code

This commit is contained in:
Zynh0722 2023-09-26 17:13:46 -07:00
parent 20b0ec7ff4
commit 061a875e15

View file

@ -3,13 +3,7 @@ mod axum_ructe;
use axum_ructe::render; use axum_ructe::render;
use axum::{ use axum::{extract::State, response::IntoResponse, routing::get, Router};
extract::State,
http::StatusCode,
response::IntoResponse,
routing::{get, post},
Json, Router,
};
use cm_lib::models::Shift; use cm_lib::models::Shift;
use diesel::result::OptionalExtension; use diesel::result::OptionalExtension;
use diesel::{ExpressionMethods, QueryDsl, SelectableHelper}; use diesel::{ExpressionMethods, QueryDsl, SelectableHelper};
@ -18,7 +12,6 @@ use diesel_async::{
AsyncMysqlConnection, RunQueryDsl, AsyncMysqlConnection, RunQueryDsl,
}; };
use dotenvy::dotenv; use dotenvy::dotenv;
use serde::{Deserialize, Serialize};
use std::net::SocketAddr; use std::net::SocketAddr;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
@ -67,7 +60,6 @@ async fn main() {
let app = Router::new() let app = Router::new()
.nest("/api", api::router()) .nest("/api", api::router())
.route("/", get(root)) .route("/", get(root))
.route("/users", post(create_user))
.with_state(state); .with_state(state);
// run our app with hyper // run our app with hyper
@ -100,32 +92,3 @@ async fn root(State(state): State<AppState>) -> impl IntoResponse {
render!(templates::home_html, open_shift) 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<CreateUser>,
) -> 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,
}