public static HttpEndpointInjectorPort ServeRestApiRequests <TProtocol>(this HttpEndpointInjectorPort port) where TProtocol : MessageProtocol { var components = port.Components; var protocol = new LazySlim <TProtocol>(factory: () => components.Resolve <TProtocol>()); port.OnRequest = (context) => { var restApiService = components.Resolve <IRestApiService>(); return(restApiService.HandleHttpRequest(context, protocol.Value.ProtocolName)); }; port.OnConfiguration += new Action <IHttpEndpointConfig>((endpointConfig) => { var platformConfig = components.Resolve <IMessagingPlatformConfiguration>(); var staticFolders = components.ResolveAll <StaticResourceFolderDescription>(); foreach (var folder in staticFolders) { endpointConfig.StaticFolders.Add(ConfigureStaticResourceFolder(folder, platformConfig.NewHttpStaticFolderConfig())); } }); return(port); }
//----------------------------------------------------------------------------------------------------------------------------------------------------- public KestrelHttpEndpoint(IMessagingPlatformConfiguration platformConfig, HttpEndpointInjectorPort port) { _name = port.Name; _configuration = (IHttpEndpointConfig)platformConfig.Endpoints[port.Name]; _handler = port.OnRequest; }