Skip to content

Commit

Permalink
use axum::body::Body as resp
Browse files Browse the repository at this point in the history
  • Loading branch information
raphamorim committed Jan 14, 2024
1 parent 754f283 commit 005c10a
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/test/mod.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
pub mod jaegar;

use http_body_util::BodyExt;
use hyper::{body::Bytes, header::HeaderValue, Error, HeaderMap, Response};
use hyper::{header::HeaderValue, Error, HeaderMap, Response};
pub use opentelemetry_api::trace::{SpanId, TraceId};
use rand::Rng;

pub type BoxBody = http_body_util::combinators::BoxBody<Bytes, hyper::Error>;

#[derive(Debug)]
pub struct TracedResponse {
resp: Response<BoxBody>,
resp: Response<axum::body::Body>,
pub trace_id: TraceId,
pub span_id: SpanId,
}

impl TracedResponse {
pub fn new(resp: Response<BoxBody>, traceparent: Traceparent) -> Self {
pub fn new(resp: Response<axum::body::Body>, traceparent: Traceparent) -> Self {
Self {
resp,
trace_id: traceparent.trace_id,
Expand All @@ -24,12 +22,12 @@ impl TracedResponse {
}

pub async fn into_bytes(self) -> Result<axum::body::Bytes, Error> {
Ok(self.resp.into_body().collect().await?.to_bytes())
Ok(self.resp.into_body().collect().await.unwrap().to_bytes())
}
}

impl std::ops::Deref for TracedResponse {
type Target = Response<BoxBody>;
type Target = Response<axum::body::Body>;

fn deref(&self) -> &Self::Target {
&self.resp
Expand Down

0 comments on commit 005c10a

Please sign in to comment.