27 lines
696 B
C#
27 lines
696 B
C#
namespace BLAIzor.Services
|
|
{
|
|
public class SubdomainMiddleware
|
|
{
|
|
private readonly RequestDelegate _next;
|
|
|
|
public SubdomainMiddleware(RequestDelegate next)
|
|
{
|
|
_next = next;
|
|
}
|
|
|
|
public async Task Invoke(HttpContext context)
|
|
{
|
|
var host = context.Request.Host.Host;
|
|
//Console.Write("Host: "+ host);
|
|
var subdomain = host.Split('.')[0]; // Assumes format: subdomain.poppixel.cloud
|
|
//Console.Write("Subdomain" + subdomain);
|
|
// Store subdomain in context for later use
|
|
context.Items["Subdomain"] = subdomain;
|
|
|
|
await _next(context);
|
|
}
|
|
}
|
|
|
|
|
|
}
|