diff --git a/crates/server/Cargo.toml b/crates/server/Cargo.toml index ac4b2f6..261c865 100644 --- a/crates/server/Cargo.toml +++ b/crates/server/Cargo.toml @@ -12,5 +12,7 @@ workspace = true [dependencies] log = { workspace = true } env_logger = { workspace = true } -tokio = { workspace = true, features = ["full"] } -axum = { workspace = true, features = ["json"] } +tokio = { workspace = true, features=["full"] } +axum = { workspace = true } +utoipa = { version = "4", features = ["axum_extras"] } +log = "0.4.21" \ No newline at end of file diff --git a/crates/server/src/main.rs b/crates/server/src/main.rs index 2db1944..e5d9d92 100644 --- a/crates/server/src/main.rs +++ b/crates/server/src/main.rs @@ -1,34 +1,29 @@ -use axum::{ - http::{StatusCode, Uri}, - routing::get, - Router, -}; -use log::warn; -use tokio::net::TcpListener; +use axum::{extract::Request, routing::{get, post}, Router}; -mod auth; -mod identity; -mod secrets; -mod sys; +use log; +use std::env; #[tokio::main] async fn main() { + env::set_var("RUST_LOG", "trace"); env_logger::init(); - + + // build our application with a route let app = Router::new() .route("/", get(root)) - .nest("/v1/auth", auth::auth_router()) - .fallback(fallback_route_unknown); + .route("/v1/secret/data/foo", post(foo)); - let listener = TcpListener::bind("[::]:8200").await.unwrap(); - warn!("Listening on: {}", listener.local_addr().unwrap()); + + + // run our app with hyper, listening globally on port 8200 + let listener = tokio::net::TcpListener::bind("127.0.0.1:8200").await.unwrap(); axum::serve(listener, app).await.unwrap(); } -async fn fallback_route_unknown(uri: Uri, body: String) -> (StatusCode, &'static str) { - log::error!("Route not found: {}, payload {}", uri, body); - - (StatusCode::NOT_FOUND, "Route not implemented") +async fn foo( req: Request) -> String { + log::debug!("`{:?}`", req); + return String::from("RoutingTest successful"); + } // basic handler that responds with a static string