Skip to content

Commit 7054131

Browse files
committed
sentry - middleware - body_to_string debug fn
1 parent 5511e9a commit 7054131

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

sentry/src/middleware.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ use hyper::{Body, Request};
99

1010
use async_trait::async_trait;
1111

12+
#[cfg(test)]
13+
pub use test_util::*;
14+
1215
pub mod auth;
1316
pub mod campaign;
1417
pub mod channel;
@@ -52,3 +55,15 @@ impl<C: Locked + 'static> Chain<C> {
5255
Ok(request)
5356
}
5457
}
58+
59+
#[cfg(test)]
60+
pub mod test_util {
61+
use axum::{body::BoxBody, response::Response};
62+
63+
/// Extracts the body as a String from the Response.
64+
///
65+
/// Used when you want to check the response body or debug a response.
66+
pub async fn body_to_string(response: Response<BoxBody>) -> String {
67+
String::from_utf8(hyper::body::to_bytes(response).await.unwrap().to_vec()).unwrap()
68+
}
69+
}

0 commit comments

Comments
 (0)