mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
refactor(api-clients): ♻ mv directory host to configuration
This commit is contained in:
parent
d383d28e67
commit
f5e0f608b1
5 changed files with 24 additions and 5 deletions
1
.env
1
.env
|
|
@ -6,6 +6,7 @@ ARCHIVAL_GIT_REPOSITORY_PATH=archives
|
|||
ARCHIVAL_GIT_USER_NAME=FilterLists Archival
|
||||
ARCHIVAL_GIT_USER_EMAIL=noreply@filterlists.com
|
||||
|
||||
DIRECTORY_HOST=directory-api
|
||||
DIRECTORY_APPLICATION_INSIGHTS_INSTRUMENTATION_KEY=
|
||||
DIRECTORY_CONNECTION_STRING=Server=directory-db;Database=filterlists;User Id=filterlists;Password=filterlists;
|
||||
DIRECTORY_DB_USER=filterlists
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ services:
|
|||
ApplicationInsights__ServerTelemetryChannelStoragePath: ${APPLICATION_INSIGHTS_SERVER_TELEMETRY_CHANNEL_STORAGE_PATH}
|
||||
ApplicationInsights__InstrumentationKey: ${ARCHIVAL_APPLICATION_INSIGHTS_INSTRUMENTATION_KEY}
|
||||
ConnectionStrings__SchedulingConnection: ${ARCHIVAL_REDIS_CONNECTION_STRING}
|
||||
Api__DirectoryHost: ${DIRECTORY_HOST}
|
||||
Git__RepositoryPath: ${ARCHIVAL_GIT_REPOSITORY_PATH}
|
||||
Git__UserName: ${ARCHIVAL_GIT_USER_NAME}
|
||||
Git__UserEmail: ${ARCHIVAL_GIT_USER_EMAIL}
|
||||
|
|
@ -44,8 +45,10 @@ services:
|
|||
image: ghcr.io/collinbarrett/filterlists-directory-api
|
||||
restart: always
|
||||
networks:
|
||||
- reverse-proxy
|
||||
- directory
|
||||
reverse-proxy:
|
||||
aliases:
|
||||
- ${DIRECTORY_HOST}
|
||||
directory:
|
||||
depends_on:
|
||||
- directory-db
|
||||
volumes:
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public static void AddInfrastructureServices(this IServiceCollection services, I
|
|||
|
||||
services.AddSharedKernelLogging(configuration);
|
||||
services.AddSchedulingServices(configuration);
|
||||
services.AddApiClients();
|
||||
services.AddApiClients(configuration);
|
||||
services.AddPersistenceServices(configuration);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
using System;
|
||||
using FilterLists.SharedKernel.Apis.Clients.Options;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Refit;
|
||||
|
||||
|
|
@ -6,11 +8,15 @@ namespace FilterLists.SharedKernel.Apis.Clients
|
|||
{
|
||||
public static class ConfigurationExtensions
|
||||
{
|
||||
public static void AddApiClients(this IServiceCollection services)
|
||||
public static void AddApiClients(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
// TODO: use SystemTextJsonContentSerializer() once less feature-limited
|
||||
services.AddRefitClient<IDirectoryApi>()
|
||||
.ConfigureHttpClient(c => c.BaseAddress = new Uri("http://directory-api"));
|
||||
.ConfigureHttpClient(c =>
|
||||
{
|
||||
var host = configuration.GetSection(ApiOptions.Key).Get<ApiOptions>().DirectoryHost;
|
||||
c.BaseAddress = new UriBuilder("http", host).Uri;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
namespace FilterLists.SharedKernel.Apis.Clients.Options
|
||||
{
|
||||
internal class ApiOptions
|
||||
{
|
||||
public const string Key = "Api";
|
||||
|
||||
public string DirectoryHost { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue