{-# LANGUAGE ImportQualifiedPost #-}

{- | Serve a XStaticFiles in your servant api:

@
type ServerAPI =
    Get '[HTML] (Html ())
        :\<|\> "xstatic" :> Raw

server :: Server ServerAPI
server = pure mempty \<|\> xstaticServant xfiles
  where
    xfiles = [XStatic.htmx]
@
-}

module Servant.XStatic (xstaticServant) where

import Servant.API (Raw)
import Servant.Server (ServerT, Tagged (..))
import XStatic (XStaticFile)
import XStatic qualified

-- | Create a 'Raw' handler.
xstaticServant :: [XStaticFile] -> ServerT Raw m
xstaticServant :: forall (m :: * -> *). [XStaticFile] -> ServerT Raw m
xstaticServant = forall {k} (s :: k) b. b -> Tagged s b
Tagged forall b c a. (b -> c) -> (a -> b) -> a -> c
. [XStaticFile] -> Application
XStatic.xstaticApp