Added args to macro

This commit is contained in:
Franklin 2023-01-24 18:06:23 -04:00
parent 0ac5d17824
commit 065921c0b5
1 changed files with 3 additions and 3 deletions

View File

@ -25,8 +25,8 @@ pub fn authenticated_route(_: TokenStream, mut input: TokenStream) -> TokenStrea
#[allow(unused_macros)]
#[macro_export]
macro_rules! authenticate_route {
() => {
let header_conversion_result: dev_dtos::dtos::user::user_dtos::UserAuthHeader = match serde_json::from_str(match request.headers().get("authentication") {
($request:expr, $client:expr) => {
let header_conversion_result: dev_dtos::dtos::user::user_dtos::UserAuthHeader = match serde_json::from_str(match $request.headers().get("authentication") {
Some(auth_header) => match auth_header.to_str() {
Ok(string) => string,
Err(_) => return actix_web_utils::extensions::typed_response::TypedHttpResponse::return_standard_error(400, err::MessageResource::new_from_str("Auth header in incorrect format.")),
@ -36,7 +36,7 @@ macro_rules! authenticate_route {
Ok(user_for_authentication) => user_for_authentication,
Err(error) => return actix_web_utils::extensions::typed_response::TypedHttpResponse::return_standard_error(401, err::MessageResource::new_from_string(error.to_string())),
};
let authenticated_user = match dev_communicators::middleware::user_svc::user_service::authenticate_user_with_token(&client, &header_conversion_result.into()).await {
let authenticated_user = match dev_communicators::middleware::user_svc::user_service::authenticate_user_with_token($client, &header_conversion_result.into()).await {
Ok(authed_user) => authed_user,
Err(error) => return actix_web_utils::extensions::typed_response::TypedHttpResponse::return_standard_error(401, err::MessageResource::new_from_string(error.to_string())),
};