summaryrefslogtreecommitdiff
path: root/src/extractors.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/extractors.rs')
-rw-r--r--src/extractors.rs24
1 files changed, 0 insertions, 24 deletions
diff --git a/src/extractors.rs b/src/extractors.rs
deleted file mode 100644
index 4d441e9..0000000
--- a/src/extractors.rs
+++ /dev/null
@@ -1,24 +0,0 @@
1use axum::{
2 extract::{Request, State},
3 http::{HeaderMap, StatusCode},
4 middleware::Next,
5 response::Response,
6};
7
8use crate::AppState;
9
10pub async fn auth(
11 State(state): State<AppState>,
12 headers: HeaderMap,
13 request: Request,
14 next: Next,
15) -> Result<Response, StatusCode> {
16 let secret = headers.get("authorization");
17 match secret {
18 Some(token) if token == state.config.apikey.as_str() => {
19 let response = next.run(request).await;
20 Ok(response)
21 }
22 _ => Err(StatusCode::UNAUTHORIZED),
23 }
24}