chore: set up skeleton project

This commit is contained in:
Jef Roosens 2025-02-23 10:31:03 +01:00
commit b6a8ee0bbe
No known key found for this signature in database
GPG key ID: 21FD3D77D56BAF49
10 changed files with 1278 additions and 0 deletions

22
src/server/mod.rs Normal file
View file

@ -0,0 +1,22 @@
use axum::{
http::{HeaderName, HeaderValue},
Router,
};
use tower_http::{set_header::SetResponseHeaderLayer, trace::TraceLayer};
#[derive(Clone)]
pub struct Context {
pub pool: crate::db::DbPool,
}
pub fn app() -> Router<Context> {
Router::new()
.layer(TraceLayer::new_for_http())
// https://gpoddernet.readthedocs.io/en/latest/api/reference/general.html#cors
// All endpoints should send this CORS header value so the endpoints can be used from web
// applications
.layer(SetResponseHeaderLayer::overriding(
HeaderName::from_static("access-control-allow-origin"),
HeaderValue::from_static("*"),
))
}