diff --git a/src/Saturn/Application.fs b/src/Saturn/Application.fs index 72d539c..5d58086 100644 --- a/src/Saturn/Application.fs +++ b/src/Saturn/Application.fs @@ -63,6 +63,7 @@ module Application = ErrorHandler: ErrorHandler option Pipelines: HttpHandler list Urls: string list + Sockets : string list MimeTypes: (string*string) list AppConfigs: (IApplicationBuilder -> IApplicationBuilder) list HostConfigs: (IHostBuilder -> IHostBuilder) list @@ -104,6 +105,7 @@ module Application = /// pipe_through endpointPipe /// use_router topRouter /// url "http://0.0.0.0:8085/" + /// socket "/tmp/socket" /// memory_cache /// use_static "static" /// use_gzip @@ -114,7 +116,7 @@ module Application = let errorHandler (ex : Exception) (logger : ILogger) = logger.LogError(EventId(), ex, "An unhandled exception has occurred while executing the request.") clearResponse >=> Giraffe.HttpStatusCodeHandlers.ServerErrors.INTERNAL_ERROR ex.Message - {Router = None; EndpointRouter = None; ErrorHandler = Some errorHandler; Pipelines = []; Urls = []; MimeTypes = []; AppConfigs = []; HostConfigs = []; ServicesConfig = []; WebHostConfigs = []; CliArguments = None; CookiesAlreadyAdded = false; NoRouter = false; NoWebhost = false; Channels = [] } + {Router = None; EndpointRouter = None; ErrorHandler = Some errorHandler; Pipelines = []; Urls = []; Sockets = []; MimeTypes = []; AppConfigs = []; HostConfigs = []; ServicesConfig = []; WebHostConfigs = []; CliArguments = None; CookiesAlreadyAdded = false; NoRouter = false; NoWebhost = false; Channels = [] } member __.Run(state: ApplicationState) : IHostBuilder = // to build the app we have to separate our configurations and our pipelines. @@ -214,6 +216,12 @@ module Application = if not (state.Urls |> List.isEmpty) then wbhst.UseUrls(state.Urls |> List.toArray) else wbhst + let wbhst = + if not (state.Sockets |> List.isEmpty) then + wbhst.ConfigureKestrel (fun options -> + state.Sockets |> List.iter options.ListenUnixSocket + ) + else wbhst let wbhst = wbhst.Configure(fun ab -> (ab, useParts) @@ -279,6 +287,11 @@ module Application = member __.Url(state, url) = {state with Urls = url::state.Urls} + ///Adds socket + [] + member __.Socket(state, socket) = + {state with Sockets = socket::state.Sockets} + ///Adds MIME types definitions as a list of (extension, mime) [] member __.AddMimeTypes(state, mimeList) =