feat: setup a backend server with axum

This commit is contained in:
2024-09-23 18:02:07 +02:00
parent 2e057eee01
commit a50d951af7
5 changed files with 173 additions and 10 deletions

12
crates/backend/src/lib.rs Normal file
View File

@ -0,0 +1,12 @@
use axum::http::{StatusCode, Uri};
use axum::{routing::get, Router};
pub fn get_router() -> Router {
Router::new()
.route("/", get(|| async { "Hello, world!" }))
.fallback(fallback)
}
async fn fallback(uri: Uri) -> (StatusCode, String) {
(StatusCode::NOT_FOUND, format!("No route for {uri}"))
}