Skip to content

Commit fb04054

Browse files
feat: Add the webp mime type based on the .webp extension (#132)
The webp mime type has been added to enable serving webp images based on the .webp file name extension through suave when running Fornax watch.
1 parent d7d66aa commit fb04054

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/Fornax/Fornax.fs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ open Suave.Sockets.Control
1414
open Suave.WebSocket
1515
open System.Reflection
1616
open Logger
17+
open Suave.Writers
1718

1819
type FornaxExiter () =
1920
interface IExiter with
@@ -105,13 +106,23 @@ let ws (webSocket : WebSocket) (context: HttpContext) =
105106
}
106107

107108
let getWebServerConfig port =
109+
let mimeTypes =
110+
defaultMimeTypesMap @@
111+
(function
112+
| ".webp" -> createMimeType "image/webp" false
113+
| _ -> None
114+
)
115+
116+
let webServerConfig =
117+
{ defaultConfig with mimeTypesMap = mimeTypes }
118+
108119
match port with
109120
| Some port ->
110-
{ defaultConfig with
121+
{ webServerConfig with
111122
bindings =
112123
[ HttpBinding.create Protocol.HTTP Net.IPAddress.Loopback port ] }
113124
| None ->
114-
defaultConfig
125+
webServerConfig
115126

116127
let getOutputDirectory (output : option<string>) (cwd : string) =
117128
match output with

0 commit comments

Comments
 (0)