A man is not dead while his name is still spoken (#1280)
This commit is contained in:
parent
6f803b548b
commit
573ff69749
1 changed files with 20 additions and 2 deletions
|
@ -2,7 +2,9 @@ use async_trait::async_trait;
|
||||||
use atuin_common::api::ErrorResponse;
|
use atuin_common::api::ErrorResponse;
|
||||||
use axum::{
|
use axum::{
|
||||||
extract::FromRequestParts,
|
extract::FromRequestParts,
|
||||||
response::IntoResponse,
|
http::Request,
|
||||||
|
middleware::Next,
|
||||||
|
response::{IntoResponse, Response},
|
||||||
routing::{delete, get, post},
|
routing::{delete, get, post},
|
||||||
Router,
|
Router,
|
||||||
};
|
};
|
||||||
|
@ -76,6 +78,18 @@ async fn teapot() -> impl IntoResponse {
|
||||||
(http::StatusCode::IM_A_TEAPOT, "🫖")
|
(http::StatusCode::IM_A_TEAPOT, "🫖")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn clacks_overhead<B>(request: Request<B>, next: Next<B>) -> Response {
|
||||||
|
let mut response = next.run(request).await;
|
||||||
|
|
||||||
|
let gnu_terry_value = "GNU Terry Pratchett";
|
||||||
|
let gnu_terry_header = "X-Clacks-Overhead";
|
||||||
|
|
||||||
|
response
|
||||||
|
.headers_mut()
|
||||||
|
.insert(gnu_terry_header, gnu_terry_value.parse().unwrap());
|
||||||
|
response
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct AppState<DB: Database> {
|
pub struct AppState<DB: Database> {
|
||||||
pub database: DB,
|
pub database: DB,
|
||||||
|
@ -107,5 +121,9 @@ pub fn router<DB: Database>(database: DB, settings: Settings<DB::Settings>) -> R
|
||||||
}
|
}
|
||||||
.fallback(teapot)
|
.fallback(teapot)
|
||||||
.with_state(AppState { database, settings })
|
.with_state(AppState { database, settings })
|
||||||
.layer(ServiceBuilder::new().layer(TraceLayer::new_for_http()))
|
.layer(
|
||||||
|
ServiceBuilder::new()
|
||||||
|
.layer(axum::middleware::from_fn(clacks_overhead))
|
||||||
|
.layer(TraceLayer::new_for_http()),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue