76 lines
2.1 KiB
C#
Executable File
76 lines
2.1 KiB
C#
Executable File
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Auth.Module.Config;
|
|
using Auth.Module.Services;
|
|
using ECommerceModule.Config;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Components.Authorization;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Http;
|
|
|
|
namespace UI.Config.Register;
|
|
|
|
public static class RegisteringServices
|
|
{
|
|
public static IServiceCollection RegisterServices(
|
|
this IServiceCollection services,
|
|
IConfiguration config
|
|
)
|
|
{
|
|
services.AddHTTPClients(config);
|
|
services.RegisteredServices();
|
|
|
|
return services;
|
|
}
|
|
|
|
public static IServiceCollection RegisteredServices(this IServiceCollection services)
|
|
{
|
|
services.AuthModuleServices();
|
|
services.ECommerceModuleServices();
|
|
|
|
// Common Services
|
|
services.AddScoped<Common.Services.IToastService, Common.Services.ToastService>();
|
|
|
|
// Commerce Module Services
|
|
|
|
return services;
|
|
}
|
|
|
|
public static IServiceCollection AddHTTPClients(
|
|
this IServiceCollection services,
|
|
IConfiguration config
|
|
)
|
|
{
|
|
var authUrl = config.GetValue<string>("ApiBaseUrls:Auth") ?? "https://api.mass-tech.net/api/v1/";
|
|
var commerceUrl = config.GetValue<string>("ApiBaseUrls:Commerce") ?? "https://ecommerceapi.mass-tech.net/api/v1/";
|
|
var cdnUrl = config.GetValue<string>("ApiBaseUrls:CDN") ?? "https://cdn.mass-tech.net/api/v1/";
|
|
|
|
services.AddHttpClient(
|
|
"Auth",
|
|
client =>
|
|
{
|
|
client.BaseAddress = new Uri(authUrl);
|
|
}
|
|
);
|
|
services.AddHttpClient(
|
|
"Commerce",
|
|
client =>
|
|
{
|
|
client.BaseAddress = new Uri(commerceUrl);
|
|
}
|
|
);
|
|
services.AddHttpClient(
|
|
"CDN",
|
|
client =>
|
|
{
|
|
client.BaseAddress = new Uri(cdnUrl);
|
|
}
|
|
);
|
|
|
|
return services;
|
|
}
|
|
}
|