Add axum server

This commit is contained in:
OtryvnoyKalendar
2025-11-06 19:04:02 +03:00
parent 5aa7917748
commit 6fbcaf9025
3 changed files with 672 additions and 2 deletions

View File

@ -1,3 +1,31 @@
fn main() {
println!("Hello, world!");
use axum::{extract::Query, response::IntoResponse, routing::delete, routing::get, routing::post};
use tokio::net::TcpListener;
async fn games_list() -> impl IntoResponse {
axum::http::StatusCode::NOT_IMPLEMENTED
}
async fn add_game() -> impl IntoResponse {
axum::http::StatusCode::NOT_IMPLEMENTED
}
async fn insert_game() -> impl IntoResponse {
axum::http::StatusCode::NOT_IMPLEMENTED
}
async fn delete_game() -> impl IntoResponse {
axum::http::StatusCode::NOT_IMPLEMENTED
}
#[tokio::main]
async fn main() {
let router = axum::Router::new()
.route("/api/games", get(games_list))
.route("/api/games", post(add_game))
.route("/api/games{id}", post(insert_game))
.route("/api/games", delete(delete_game));
let addr = "127.0.0.1:8000";
let listener = TcpListener::bind(addr).await.unwrap();
println!("listening at {addr}");
axum::serve(listener, router).await.unwrap();
}