mirror of
https://github.com/CannedNet/CannedNet.git
synced 2026-10-26 23:48:58 -07:00
basic admin panel stuff
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
namespace CannedNet.Admin.Services;
|
||||
|
||||
public class AdminApiKeyHandler : DelegatingHandler
|
||||
{
|
||||
private readonly string _apiKey;
|
||||
|
||||
public AdminApiKeyHandler(IConfiguration config)
|
||||
{
|
||||
_apiKey = config.GetValue<string>("Admin:ApiKey")
|
||||
?? config.GetValue<string>("AdminApiKey")
|
||||
?? "";
|
||||
}
|
||||
|
||||
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_apiKey))
|
||||
request.Headers.Add("X-Admin-Api-Key", _apiKey);
|
||||
|
||||
return await base.SendAsync(request, cancellationToken);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user