-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from mdsol/support-middleware
Support reqwest_middleware and OpenTelemetry
- Loading branch information
Showing
8 changed files
with
103 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "mauth-client" | ||
version = "0.4.0" | ||
version = "0.5.0" | ||
authors = ["Mason Gup <[email protected]>"] | ||
edition = "2021" | ||
documentation = "https://docs.rs/mauth-client/" | ||
|
@@ -14,6 +14,9 @@ categories = ["authentication", "web-programming"] | |
|
||
[dependencies] | ||
reqwest = { version = "0.12", features = ["json"] } | ||
reqwest-middleware = "0.4" | ||
reqwest-tracing = { version = "0.5.5", optional = true } | ||
async-trait = ">= 0.1.83" | ||
url = "2" | ||
serde = { version = "1", features = ["derive"] } | ||
serde_json = "1" | ||
|
@@ -25,7 +28,7 @@ tokio = { version = "1", features = ["fs"] } | |
tower = { version = "0.4", optional = true } | ||
axum = { version = ">= 0.7.2", optional = true } | ||
futures-core = { version = "0.3", optional = true } | ||
http = { version = "1", optional = true } | ||
http = "1" | ||
bytes = { version = "1", optional = true } | ||
thiserror = "1" | ||
mauth-core = "0.5" | ||
|
@@ -34,4 +37,6 @@ mauth-core = "0.5" | |
tokio = { version = "1", features = ["rt-multi-thread", "macros"] } | ||
|
||
[features] | ||
axum-service = ["tower", "futures-core", "axum", "http", "bytes"] | ||
axum-service = ["tower", "futures-core", "axum", "bytes"] | ||
tracing-otel-26 = ["reqwest-tracing/opentelemetry_0_26"] | ||
tracing-otel-27 = ["reqwest-tracing/opentelemetry_0_27"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use http::Extensions; | ||
use reqwest::{Request, Response}; | ||
use reqwest_middleware::{Middleware, Next, Result}; | ||
|
||
use crate::{sign_outgoing::SigningError, MAuthInfo}; | ||
|
||
#[async_trait::async_trait] | ||
impl Middleware for MAuthInfo { | ||
#[must_use] | ||
async fn handle( | ||
&self, | ||
mut req: Request, | ||
extensions: &mut Extensions, | ||
next: Next<'_>, | ||
) -> Result<Response> { | ||
self.sign_request(&mut req)?; | ||
next.run(req, extensions).await | ||
} | ||
} | ||
|
||
impl From<SigningError> for reqwest_middleware::Error { | ||
fn from(value: SigningError) -> Self { | ||
reqwest_middleware::Error::Middleware(value.into()) | ||
} | ||
} |
Oops, something went wrong.