chore: set up skeleton project
This commit is contained in:
commit
b6a8ee0bbe
10 changed files with 1278 additions and 0 deletions
22
src/server/mod.rs
Normal file
22
src/server/mod.rs
Normal 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("*"),
|
||||
))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue