hello-shop/samples/MultiTenancySample/MultiTenancySample.ServiceDefaults/MultiTenancyExtensions.cs

27 lines
816 B
C#
Raw Normal View History

2024-07-05 11:25:58 +00:00
// Copyright (c) HelloShop Corporation. All rights reserved.
// See the license file in the project root for more information.
using Microsoft.AspNetCore.Builder;
2024-04-28 08:00:15 +00:00
using Microsoft.Extensions.DependencyInjection;
namespace MultiTenancySample.ServiceDefaults
{
public static class MultiTenancyExtensions
{
public static IServiceCollection AddMultiTenancy(this IServiceCollection services)
{
services.AddScoped<ICurrentTenant, CurrentTenant>();
services.AddScoped<ITenantIdProvider, TenantIdProvider>();
return services.AddScoped<TenantMiddleware>();
}
public static IApplicationBuilder UseMultiTenancy(this IApplicationBuilder app)
{
app.UseMiddleware<TenantMiddleware>();
return app;
}
}
}