Skip to content

Commit

Permalink
fix for case sensitivity (#2043)
Browse files Browse the repository at this point in the history
  • Loading branch information
cjus authored Feb 14, 2025
1 parent 55e73a0 commit b2a7784
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions apps/framework-cli/src/cli/local_webserver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -625,10 +625,14 @@ async fn ingest_route(
MessageType::Info,
Message {
action: "POST".to_string(),
details: route.to_str().unwrap().to_string().to_string(),
details: route.to_str().unwrap().to_string(),
}
);

debug!("Attempting to find route: {:?}", route);
let route_table_read = route_table.read().await;
debug!("Available routes: {:?}", route_table_read.keys());

let auth_header = req.headers().get(hyper::header::AUTHORIZATION);

if !check_authorization(auth_header, &MOOSE_INGEST_API_KEY, &jwt_config).await {
Expand All @@ -639,8 +643,14 @@ async fn ingest_route(
)));
}

match route_table.read().await.get(&route) {
Some(route_meta) => match route_meta.format {
// Case-insensitive route matching
let route_str = route.to_str().unwrap().to_lowercase();
let matching_route = route_table_read
.iter()
.find(|(k, _)| k.to_str().unwrap_or("").to_lowercase().eq(&route_str));

match matching_route {
Some((_, route_meta)) => match route_meta.format {
EndpointIngestionFormat::Json => Ok(handle_json_req(
&configured_producer,
&route_meta.topic_name,
Expand All @@ -660,7 +670,11 @@ async fn ingest_route(
},
None => {
if !is_prod {
println!("Ingestion route {:?} not found.", route);
println!(
"Ingestion route {:?} not found. Available routes: {:?}",
route,
route_table_read.keys()
);
}
Response::builder()
.status(StatusCode::NOT_FOUND)
Expand Down

0 comments on commit b2a7784

Please sign in to comment.