Skip to content

Commit

Permalink
Fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugo-C committed Nov 5, 2023
1 parent a4afffd commit 2d7b6a6
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,18 +195,19 @@ fn map_status(status: Status) -> SpanStatus {

fn request_to_header_map(request: &Request) -> BTreeMap<String, String> {
BTreeMap::from_iter(
request.headers().iter().map(
|header| (header.name().to_string(), header.value().to_string())
)
request
.headers()
.iter()
.map(|header| (header.name().to_string(), header.value().to_string())),
)
}

#[cfg(test)]
mod tests {
use rocket::http::Header;
use crate::{request_to_header_map, request_to_query_string, request_to_transaction_name};
use rocket::local::asynchronous::Client;
use rocket::http::ContentType;
use rocket::http::Header;
use rocket::local::asynchronous::Client;

#[rocket::async_test]
async fn request_to_sentry_transaction_name_get_no_path() {
Expand Down Expand Up @@ -293,13 +294,20 @@ mod tests {
async fn request_to_header_map_multiple() {
let rocket = rocket::build();
let client = Client::tracked(rocket).await.unwrap();
let request = client.get("/")
let request = client
.get("/")
.header(ContentType::JSON)
.header(Header::new("custom-key", "custom-value"));

let header_map = request_to_header_map(request.inner());

assert_eq!(header_map.get("custom-key"), Some(&"custom-value".to_string()));
assert_eq!(header_map.get("Content-Type"), Some(&"application/json".to_string()));
assert_eq!(
header_map.get("custom-key"),
Some(&"custom-value".to_string())
);
assert_eq!(
header_map.get("Content-Type"),
Some(&"application/json".to_string())
);
}
}

0 comments on commit 2d7b6a6

Please sign in to comment.