From 2443dbe1d5e10f0f0a2b4d3b5af281348e4f4ad6 Mon Sep 17 00:00:00 2001 From: Yanik Ceulemans Date: Sat, 27 Sep 2025 16:55:44 +0200 Subject: [PATCH] feat: Add the webp mime type based on the .webp extension 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. --- src/Fornax/Fornax.fs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Fornax/Fornax.fs b/src/Fornax/Fornax.fs index 7757c41..b2ffd18 100644 --- a/src/Fornax/Fornax.fs +++ b/src/Fornax/Fornax.fs @@ -14,6 +14,7 @@ open Suave.Sockets.Control open Suave.WebSocket open System.Reflection open Logger +open Suave.Writers type FornaxExiter () = interface IExiter with @@ -105,13 +106,23 @@ let ws (webSocket : WebSocket) (context: HttpContext) = } let getWebServerConfig port = + let mimeTypes = + defaultMimeTypesMap @@ + (function + | ".webp" -> createMimeType "image/webp" false + | _ -> None + ) + + let webServerConfig = + { defaultConfig with mimeTypesMap = mimeTypes } + match port with | Some port -> - { defaultConfig with + { webServerConfig with bindings = [ HttpBinding.create Protocol.HTTP Net.IPAddress.Loopback port ] } | None -> - defaultConfig + webServerConfig let getOutputDirectory (output : option) (cwd : string) = match output with