Refactor API key location to use enum instead of string
Changed EndpointAuthApiKeyAddTo from string? to ApiKeyLocation? enum in RecActionDto for type safety. Updated related logic in InvokeRecActionCommandHandler to use the enum, and added the necessary using directive for ReC.Domain.Constants.
This commit is contained in:
@@ -27,7 +27,7 @@ public record RecActionDto
|
||||
|
||||
public string? EndpointAuthApiValue { get; init; }
|
||||
|
||||
public string? EndpointAuthApiKeyAddTo { get; init; }
|
||||
public ApiKeyLocation? EndpointAuthApiKeyAddTo { get; init; }
|
||||
|
||||
public string? EndpointAuthToken { get; init; }
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ using ReC.Application.Common.Constants;
|
||||
using ReC.Application.Common.Dto;
|
||||
using ReC.Application.Common.Exceptions;
|
||||
using ReC.Application.OutResults.Commands;
|
||||
using ReC.Domain.Constants;
|
||||
using System.Net;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
@@ -63,7 +64,7 @@ public class InvokeRecActionCommandHandler(
|
||||
case "API Key":
|
||||
if (action.EndpointAuthApiKey is string apiKey && action.EndpointAuthApiValue is string apiValue)
|
||||
{
|
||||
if (action.EndpointAuthApiKeyAddTo == "Header")
|
||||
if (action.EndpointAuthApiKeyAddTo == ApiKeyLocation.Header)
|
||||
{
|
||||
httpReq.Headers.Add(apiKey, apiValue);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user