From e4832b4cf36ba0eaed298ee458498eddd7176590 Mon Sep 17 00:00:00 2001 From: FxQnLr Date: Sun, 11 Feb 2024 21:17:58 +0100 Subject: fix clippy --- src/auth.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/auth.rs') diff --git a/src/auth.rs b/src/auth.rs index 90d920f..0321ade 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -1,17 +1,17 @@ use axum::http::{StatusCode, HeaderValue}; use axum::http::header::ToStrError; use tracing::{debug, error, trace}; -use crate::auth::AuthError::{MissingSecret, WrongSecret}; +use crate::auth::Error::{MissingSecret, WrongSecret}; use crate::config::SETTINGS; -pub fn auth(secret: Option<&HeaderValue>) -> Result { +pub fn auth(secret: Option<&HeaderValue>) -> Result { debug!("auth request with secret {:?}", secret); if let Some(value) = secret { trace!("value exists"); let key = SETTINGS .get_string("apikey") - .map_err(AuthError::Config)?; - if value.to_str().map_err(AuthError::HeaderToStr)? == key.as_str() { + .map_err(Error::Config)?; + if value.to_str().map_err(Error::HeaderToStr)? == key.as_str() { debug!("successful auth"); Ok(true) } else { @@ -25,14 +25,14 @@ pub fn auth(secret: Option<&HeaderValue>) -> Result { } #[derive(Debug)] -pub enum AuthError { +pub enum Error { WrongSecret, MissingSecret, Config(config::ConfigError), HeaderToStr(ToStrError) } -impl AuthError { +impl Error { pub fn get(self) -> (StatusCode, &'static str) { match self { Self::WrongSecret => (StatusCode::UNAUTHORIZED, "Wrong credentials"), -- cgit v1.2.3