use axum::{ extract::{Request, State}, http::{HeaderMap, StatusCode}, middleware::Next, response::Response, }; use crate::AppState; pub async fn auth( State(state): State, headers: HeaderMap, request: Request, next: Next, ) -> Result { let secret = headers.get("authorization"); match secret { Some(token) if token == state.config.apikey.as_str() => { let response = next.run(request).await; Ok(response) } _ => Err(StatusCode::UNAUTHORIZED), } }