From d4c6e9804f3782ac85cae4626807c996e2954516 Mon Sep 17 00:00:00 2001 From: Ihor Date: Fri, 20 Nov 2020 14:54:01 +0100 Subject: [PATCH 1/5] Create README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..4a82e25 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# microtools-rs +Minimal toolbox to write backend services in rust From f571bca813f7b379d3a9a0a924bbd2fc42305c18 Mon Sep 17 00:00:00 2001 From: Ihor M Date: Fri, 20 Nov 2020 15:54:07 +0100 Subject: [PATCH 2/5] description updates --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 84c2eaa..04b5649 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "microtools" version = "0.1.0" -authors = ["Bodo Junglas "] +authors = ["Bodo Junglas ", "Ihor Mordashev Date: Fri, 20 Nov 2020 15:54:23 +0100 Subject: [PATCH 3/5] clippy - refactoring --- src/auth_middleware.rs | 5 +---- src/problem.rs | 4 ---- src/status.rs | 2 +- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/auth_middleware.rs b/src/auth_middleware.rs index 8c8ba3e..13645c0 100644 --- a/src/auth_middleware.rs +++ b/src/auth_middleware.rs @@ -32,10 +32,7 @@ impl AuthContext { } pub fn admin_scope(auth_context: &AuthContext) -> bool { - match auth_context.subject { - Subject::Admin(_) => true, - _ => false, - } + matches!(auth_context.subject, Subject::Admin(_)) } impl FromRequest for AuthContext { diff --git a/src/problem.rs b/src/problem.rs index 984b51e..c22c84f 100644 --- a/src/problem.rs +++ b/src/problem.rs @@ -1,9 +1,5 @@ -use actix; -use actix_web; use log::error; use serde_derive::{Deserialize, Serialize}; -use serde_json; -use std; #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] pub struct Problem { diff --git a/src/status.rs b/src/status.rs index a38a133..d15f68f 100644 --- a/src/status.rs +++ b/src/status.rs @@ -20,7 +20,7 @@ impl Status { } } -pub fn status_resource(version: Option) -> impl FnOnce(&mut Resource) -> () { +pub fn status_resource(version: Option) -> impl FnOnce(&mut Resource) { let status = Status::new(version); |r: &mut Resource| r.method(Method::GET).f(move |_| status.status()) From e21ce6baeabf81ff07aecf68b556dc5c001e0f73 Mon Sep 17 00:00:00 2001 From: Ihor M Date: Fri, 20 Nov 2020 16:03:25 +0100 Subject: [PATCH 4/5] clippy - refactoring - part 2 --- src/gatekeeper.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gatekeeper.rs b/src/gatekeeper.rs index 3e7b397..4f381c8 100644 --- a/src/gatekeeper.rs +++ b/src/gatekeeper.rs @@ -43,7 +43,7 @@ impl TokenCreator { let mut scopes_map: Map = Map::new(); for (key, values_raw) in scopes { - let values = values_raw.iter().map(|v| Value::String(v.to_string())).collect(); + let values = values_raw.iter().map(|&v| Value::String(v.to_string())).collect(); scopes_map.insert(key.to_string(), Value::Array(values)); } From c9c0aeda8e87c16b1112f2a98f725c1a783c6124 Mon Sep 17 00:00:00 2001 From: Ihor M Date: Fri, 20 Nov 2020 16:05:37 +0100 Subject: [PATCH 5/5] clippy - refactoring - part 3 --- src/gatekeeper.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gatekeeper.rs b/src/gatekeeper.rs index 4f381c8..0b26a0c 100644 --- a/src/gatekeeper.rs +++ b/src/gatekeeper.rs @@ -44,7 +44,7 @@ impl TokenCreator { for (key, values_raw) in scopes { let values = values_raw.iter().map(|&v| Value::String(v.to_string())).collect(); - scopes_map.insert(key.to_string(), Value::Array(values)); + scopes_map.insert((*key).to_string(), Value::Array(values)); } claims.insert("scopes".to_string(), Value::Object(scopes_map));