Skip to content

Commit

Permalink
Rename to BaseUriLayer
Browse files Browse the repository at this point in the history
  • Loading branch information
kazk committed Jun 5, 2021
1 parent 8c540c0 commit 38782b5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions kube/src/client/config_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use tower::util::Either;
#[cfg(any(feature = "native-tls", feature = "rustls-tls"))] use super::tls;
use super::{
auth::Auth,
middleware::{AddAuthorizationLayer, AuthLayer, RefreshTokenLayer, SetBaseUriLayer},
middleware::{AddAuthorizationLayer, AuthLayer, BaseUriLayer, RefreshTokenLayer},
};
use crate::{Config, Result};

Expand All @@ -16,7 +16,7 @@ use crate::{Config, Result};
/// This trait is sealed and cannot be implemented.
pub trait ConfigExt: private::Sealed {
/// Layer to set the base URI of requests to the configured server.
fn base_uri_layer(&self) -> SetBaseUriLayer;
fn base_uri_layer(&self) -> BaseUriLayer;

/// Optional layer to set up `Authorization` header depending on the config.
fn auth_layer(&self) -> Result<Option<AuthLayer>>;
Expand Down Expand Up @@ -106,8 +106,8 @@ mod private {
}

impl ConfigExt for Config {
fn base_uri_layer(&self) -> SetBaseUriLayer {
SetBaseUriLayer::new(self.cluster_url.clone())
fn base_uri_layer(&self) -> BaseUriLayer {
BaseUriLayer::new(self.cluster_url.clone())
}

fn auth_layer(&self) -> Result<Option<AuthLayer>> {
Expand Down
18 changes: 9 additions & 9 deletions kube/src/client/middleware/base_uri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@
use http::{uri, Request};
use tower::{Layer, Service};

/// Layer that applies [`SetBaseUri`] which makes all requests relative to the base URI.
/// Layer that applies [`BaseUri`] which makes all requests relative to the URI.
///
/// Path in `base_uri` is preseved.
/// Path in the base URI is preseved.
#[derive(Debug, Clone)]
pub struct SetBaseUriLayer {
pub struct BaseUriLayer {
base_uri: http::Uri,
}

impl SetBaseUriLayer {
impl BaseUriLayer {
/// Set base URI of requests.
pub fn new(base_uri: http::Uri) -> Self {
Self { base_uri }
}
}

impl<S> Layer<S> for SetBaseUriLayer {
type Service = SetBaseUri<S>;
impl<S> Layer<S> for BaseUriLayer {
type Service = BaseUri<S>;

fn layer(&self, inner: S) -> Self::Service {
SetBaseUri {
BaseUri {
base_uri: self.base_uri.clone(),
inner,
}
Expand All @@ -30,12 +30,12 @@ impl<S> Layer<S> for SetBaseUriLayer {

/// Middleware that sets base URI so that all requests are relative to it.
#[derive(Debug, Clone)]
pub struct SetBaseUri<S> {
pub struct BaseUri<S> {
base_uri: http::Uri,
inner: S,
}

impl<S, ReqBody> Service<Request<ReqBody>> for SetBaseUri<S>
impl<S, ReqBody> Service<Request<ReqBody>> for BaseUri<S>
where
S: Service<Request<ReqBody>>,
{
Expand Down
2 changes: 1 addition & 1 deletion kube/src/client/middleware/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mod base_uri;
mod refresh_token;

pub(crate) use add_authorization::AddAuthorizationLayer;
pub use base_uri::{SetBaseUri, SetBaseUriLayer};
pub use base_uri::{BaseUri, BaseUriLayer};
pub(crate) use refresh_token::RefreshTokenLayer;
/// Layer to set up `Authorization` header depending on the config.
pub struct AuthLayer(pub(crate) Either<AddAuthorizationLayer, RefreshTokenLayer>);
Expand Down

0 comments on commit 38782b5

Please sign in to comment.