Skip to content

Commit

Permalink
Add very basic access logs for requests coming in
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Jun 4, 2024
1 parent efc14ed commit 416fb01
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/service.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use futures::future::join_all;
use hyper_util::client::legacy::{Client, ResponseFuture};
use hyper_util::rt::TokioExecutor;
use log::{debug, warn};
use log::{debug, info, warn};
use std::{collections::HashMap, sync::Arc};

use http_body_util::{BodyExt, Full};
Expand All @@ -23,7 +23,19 @@ pub async fn handle_request(
) -> Result<Response<BoxBody>> {
let method = req.method();
let uri = req.uri().clone();
let path = uri.path();
let headers = req.headers().clone();
let user_agent = match headers.get("user-agent") {
Some(header) => {
if let Ok(v) = header.to_str() {
v
} else {
"no-agent"
}
},
None => "no-agent",
};
info!("{method} {path} {user_agent}");

// All store/envelope requests are POST
if method != Method::POST {
Expand Down

0 comments on commit 416fb01

Please sign in to comment.