Skip to content
This repository has been archived by the owner on Jul 17, 2023. It is now read-only.

Commit

Permalink
Merge pull request #3 from 21re/aloise-patch-1
Browse files Browse the repository at this point in the history
Create README.md
  • Loading branch information
Ihor authored Nov 20, 2020
2 parents 3eba5f8 + c9c0aed commit 5361b69
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "microtools"
version = "0.1.0"
authors = ["Bodo Junglas <[email protected]>"]
authors = ["Bodo Junglas <[email protected]>", "Ihor Mordashev <[email protected]"]
edition = "2018"

[dependencies]
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# microtools-rs
Minimal toolbox to write backend services in rust
5 changes: 1 addition & 4 deletions src/auth_middleware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<S> FromRequest<S> for AuthContext {
Expand Down
4 changes: 2 additions & 2 deletions src/gatekeeper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ impl TokenCreator {
let mut scopes_map: Map<String, Value> = Map::new();

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));
let values = values_raw.iter().map(|&v| Value::String(v.to_string())).collect();
scopes_map.insert((*key).to_string(), Value::Array(values));
}

claims.insert("scopes".to_string(), Value::Object(scopes_map));
Expand Down
4 changes: 0 additions & 4 deletions src/problem.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl Status {
}
}

pub fn status_resource<V: ToString, S: 'static>(version: Option<V>) -> impl FnOnce(&mut Resource<S>) -> () {
pub fn status_resource<V: ToString, S: 'static>(version: Option<V>) -> impl FnOnce(&mut Resource<S>) {
let status = Status::new(version);

|r: &mut Resource<S>| r.method(Method::GET).f(move |_| status.status())
Expand Down

0 comments on commit 5361b69

Please sign in to comment.