summaryrefslogtreecommitdiff
path: root/src/registry.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/registry.rs')
-rw-r--r--src/registry.rs32
1 files changed, 10 insertions, 22 deletions
diff --git a/src/registry.rs b/src/registry.rs
index c23a395..45cf625 100644
--- a/src/registry.rs
+++ b/src/registry.rs
@@ -59,23 +59,6 @@ struct AuthState {
stage: AuthStage,
}
-struct Auth {
- states: HashMap<String, AuthState>,
-}
-
-impl Auth {
- fn new(infos: Vec<AuthInfo>) -> Self {
- let mut states = HashMap::new();
- for info in infos {
- states.insert(info.host.clone(), AuthState {
- info: info,
- stage: AuthStage::Idle,
- });
- }
-
- return Auth { states };
- }
-}
impl AuthState {
fn add_to_request<T>(&self, req: ureq::RequestBuilder<T>) -> ureq::RequestBuilder<T> {
@@ -165,14 +148,19 @@ enum RegistryError {
}
pub struct HttpRegistry {
- auth: RefCell<Auth>,
+ auth: RefCell<HashMap<String, AuthState>>,
}
impl HttpRegistry {
pub fn new(infos: Vec<AuthInfo>) -> Self {
- return HttpRegistry {
- auth: RefCell::new(Auth::new(infos)),
- };
+ let mut states = HashMap::new();
+ for info in infos {
+ states.insert(info.host.clone(), AuthState {
+ info: info,
+ stage: AuthStage::Idle,
+ });
+ }
+ return HttpRegistry { auth: RefCell::new(states) };
}
fn perform_request(
@@ -182,7 +170,7 @@ impl HttpRegistry {
accept: &'static str,
) -> Result<ureq::http::Response<ureq::Body>, RegistryError> {
let mut auth = self.auth.borrow_mut();
- let mut state = auth.states.get_mut(registry);
+ let mut state = auth.get_mut(registry);
let url = format!("https://{}{}", registry, &url);