Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/Saturn/Application.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -279,6 +287,11 @@ module Application =
member __.Url(state, url) =
{state with Urls = url::state.Urls}

///Adds socket
[<CustomOperation("socket")>]
member __.Socket(state, socket) =
{state with Sockets = socket::state.Sockets}

///Adds MIME types definitions as a list of (extension, mime)
[<CustomOperation("use_mime_types")>]
member __.AddMimeTypes(state, mimeList) =
Expand Down
Loading