LocaleDetectionMiddleware Pennington.Localization
Middleware that detects the locale from the URL path prefix, populates LocaleContext, and rewrites the request path to strip the locale segment. This allows Razor components to use a single @page directive without duplicating routes per locale.
Constructors
.ctor
#public LocaleDetectionMiddleware(RequestDelegate next, LocalizationOptions localization);Creates the middleware.
Parameters
nextRequestDelegatelocalizationLocalizationOptions
Methods
Invoke
#public Task Invoke(HttpContext context);Processes the request: detects the locale, populates LocaleContext, and strips the locale prefix from the request path.
Parameters
contextHttpContext
Returns
TaskPennington.Localization.LocaleDetectionMiddleware
namespace Pennington.Localization;
/// Middleware that detects the locale from the URL path prefix, populates LocaleContext, and rewrites the request path to strip the locale segment. This allows Razor components to use a single @page directive without duplicating routes per locale.
public class LocaleDetectionMiddleware
{
/// Creates the middleware.
public LocaleDetectionMiddleware(RequestDelegate next, LocalizationOptions localization);
/// Processes the request: detects the locale, populates LocaleContext, and strips the locale prefix from the request path.
public Task Invoke(HttpContext context);
}