-
-
Notifications
You must be signed in to change notification settings - Fork 332
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
ConfigExt::auth_layer
hiding details
- Loading branch information
Showing
3 changed files
with
27 additions
and
17 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
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 |
---|---|---|
@@ -1,8 +1,21 @@ | ||
//! Middleware types returned from `ConfigExt` methods. | ||
use tower::{util::Either, Layer}; | ||
|
||
mod add_authorization; | ||
mod base_uri; | ||
mod refresh_token; | ||
|
||
pub(crate) use add_authorization::AddAuthorizationLayer; | ||
pub use base_uri::{SetBaseUri, SetBaseUriLayer}; | ||
pub(crate) use refresh_token::RefreshTokenLayer; | ||
/// Layer to set up `Authorization` header depending on the config. | ||
pub struct AuthLayer(pub(crate) Either<AddAuthorizationLayer, RefreshTokenLayer>); | ||
|
||
impl<S> Layer<S> for AuthLayer { | ||
type Service = | ||
Either<<AddAuthorizationLayer as Layer<S>>::Service, <RefreshTokenLayer as Layer<S>>::Service>; | ||
|
||
fn layer(&self, inner: S) -> Self::Service { | ||
self.0.layer(inner) | ||
} | ||
} |