base inertia setup

This commit is contained in:
LeNei
2025-03-28 10:00:09 +01:00
parent 1f38e1818b
commit 15e834060d
25 changed files with 4683 additions and 19 deletions

22
src/api/mod.rs Normal file
View File

@@ -0,0 +1,22 @@
use axum::{Router, routing::get};
use http::{Method, StatusCode};
use tower_http::cors::{Any, CorsLayer};
use crate::config::ApiContext;
#[tracing::instrument(name = "Ping")]
async fn ping() -> StatusCode {
StatusCode::OK
}
pub fn routes(api_context: ApiContext) -> Router {
let cors = CorsLayer::new()
// allow `GET` and `POST` when accessing the resource
.allow_methods([Method::GET, Method::POST])
// allow requests from any origin
.allow_origin(Any);
Router::new()
.route("/ping", get(ping))
.layer(cors)
.with_state(api_context)
}