diff options
author | Paul Oliver <contact@pauloliver.dev> | 2025-09-07 19:23:37 +0000 |
---|---|---|
committer | Paul Oliver <contact@pauloliver.dev> | 2025-09-07 19:49:03 +0000 |
commit | 89aab732dc3d484b99c0761728285bca6f6b1ba0 (patch) | |
tree | e2b4ca6656758dc9f398b9b1de2e6d92670b77df /hsm-web/Hsm/Web.hs | |
parent | ef0713cbd90d6b84da7ea67e6dfc1fe5ab5bff86 (diff) |
Diffstat (limited to 'hsm-web/Hsm/Web.hs')
-rw-r--r-- | hsm-web/Hsm/Web.hs | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/hsm-web/Hsm/Web.hs b/hsm-web/Hsm/Web.hs index 975f556..b8f8881 100644 --- a/hsm-web/Hsm/Web.hs +++ b/hsm-web/Hsm/Web.hs @@ -5,24 +5,32 @@ module Hsm.Web ( Web , runServer , runWeb - ) where - -import Effectful (Dispatch(Static), DispatchOf, Eff, IOE, (:>)) -import Effectful.Dispatch.Static (SideEffects(WithSideEffects), StaticRep, evalStaticRep, getStaticRep, unEff, unsafeEff) + ) +where + +import Effectful (Dispatch (Static), DispatchOf, Eff, IOE, (:>)) +import Effectful.Dispatch.Static + ( SideEffects (WithSideEffects) + , StaticRep + , evalStaticRep + , getStaticRep + , unEff + , unsafeEff + ) import Effectful.Dispatch.Static.Primitive (Env) import Effectful.Exception (finally) import Hsm.Cam (Cam, capturePng) -import Hsm.Log (Log, Severity(Info, Trace), logMsg, makeLoggerIO) +import Hsm.Log (Log, Severity (Info, Trace), logMsg, makeLoggerIO) import Network.Wai.Handler.Warp (defaultSettings, setLogger) import Paths_hsm_web (getDataFileName) -import Web.Scotty (Options(settings, verbose), defaultOptions, file, get, liftIO, raw, scottyOpts, setHeader) +import Web.Scotty (Options (settings, verbose), defaultOptions, file, get, liftIO, raw, scottyOpts, setHeader) data Web (a :: * -> *) (b :: *) type instance DispatchOf Web = Static WithSideEffects -newtype instance StaticRep Web = - Web Options +newtype instance StaticRep Web + = Web Options server :: (Cam :> es, Log "cam" :> es) => Options -> Env es -> IO () server options env = do @@ -46,6 +54,6 @@ runWeb :: (IOE :> es, Log "scotty" :> es, Log "web" :> es) => Eff (Web : es) a - runWeb action = do logMsg @"web" Info "Registering logger for scotty web server" scottyLogger <- makeLoggerIO @"scotty" >>= return . logRequest - evalStaticRep (Web $ defaultOptions {verbose = 0, settings = setLogger scottyLogger defaultSettings}) action + evalStaticRep (Web $ defaultOptions{verbose = 0, settings = setLogger scottyLogger defaultSettings}) action where logRequest loggerIO request status fileSize = loggerIO Trace $ unwords [show request, show status, show fileSize] |