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:
2025-12-12 13:17:54 +01:00
parent 6d04a4afd1
commit 3b77345aee
2 changed files with 3 additions and 2 deletions

View File

@@ -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; }

View File

@@ -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);
}