Path: redb-route/redb.Route.Http.Hosting/Extensions/ServiceCollectionExtensions.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.Http.Hosting/Extensions/ServiceCollectionExtensions.cs ---- using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; namespace redb.Route.Http; /// /// Registration for the shared Kestrel hosting infrastructure. /// public static class HostingServiceCollectionExtensions { /// /// Registers the shared as a single instance for the container. /// Idempotent () /// so every HTTP-based transport (redb.Route.Http, redb.Route.As2, …) can call it and they all /// share ONE server manager — one Kestrel per host:port, with routes multiplexed across connectors. /// public static IServiceCollection AddRedbRouteHttpHosting(this IServiceCollection services) => AddRedbRouteHttpHosting(services, null); /// /// Registers the shared host and applies to its /// . Safe to call more than once: every call contributes its /// configuration, the manager is still created once, and the options are read when the manager /// is first resolved. Connectors register the host with no configuration; the process that /// owns the deployment (a worker, a test fixture) is the one that adds trusted proxies. /// Example: services.AddRedbRouteHttpHosting(o => o.TrustedProxies.Add("10.0.0.5")); /// public static IServiceCollection AddRedbRouteHttpHosting( this IServiceCollection services, Action? configure) { services.AddOptions(); if (configure is not null) services.Configure(configure); services.TryAddSingleton(sp => new SharedHttpServerManager( sp.GetRequiredService>().Value, sp.GetService()?.CreateLogger())); return services; } }