Skip to content

Commit

Permalink
Merge pull request jorgenpt#1 from game-science/login
Browse files Browse the repository at this point in the history
Adding /login route that sends back headers from the request
  • Loading branch information
gs-danielgillies authored Jan 29, 2024
2 parents 62c7bf7 + 1a47fe3 commit 02311cd
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/bin/rugs_metadata_server.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use anyhow::{Context, Result};
use axum::{
body::Body,
http::{self, Request, StatusCode},
middleware::{self, Next},
response::IntoResponse,
Expand All @@ -8,6 +9,7 @@ use axum::{
};
use base64::prelude::*;
use clap::Parser;
use hyper::HeaderMap;
use sqlx::SqlitePool;
use tokio::sync::RwLock;
use tower::ServiceBuilder;
Expand Down Expand Up @@ -99,6 +101,11 @@ async fn auth<B>(req: Request<B>, next: Next<B>, required_auth: String) -> impl
/// Just returns a 200.
pub async fn health() {}

/// Return header info
pub async fn login(request: Request<Body>) -> HeaderMap {
request.headers().to_owned()
}

#[tokio::main]
async fn main() -> Result<()> {
let (exit_tx, exit_rx) = tokio::sync::oneshot::channel::<()>();
Expand Down Expand Up @@ -158,7 +165,8 @@ fn app(config: Config, pool: SqlitePool) -> Router {
&config.request_root,
Router::new()
.nest("/api", Router::new().merge(user_routes).merge(ci_routes))
.route("/health", get(health)),
.route("/health", get(health))
.route("/login", get(login)),
);

// We expose the basic `health` endpoint under both `/health` and `/<request_root>/health` if the
Expand Down

0 comments on commit 02311cd

Please sign in to comment.