Move Accept HTML in Yore.Servant
This commit is contained in:
+9
-2
@@ -1,11 +1,13 @@
|
||||
{-# LANGUAGE OverloadedRecordDot #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE TypeFamilies #-}
|
||||
|
||||
module Yore.Servant (GetSendfile, Sendfile (..)) where
|
||||
module Yore.Servant (GetSendfile, Sendfile (..), HTML) where
|
||||
|
||||
import Network.HTTP.Media ((//), (/:))
|
||||
import Network.HTTP.Types (ResponseHeaders, status200)
|
||||
import Network.Wai (responseFile)
|
||||
import Servant (HasServer (..))
|
||||
import Servant (Accept (..), HasServer (..))
|
||||
import Servant.Server.Internal.Delayed (runAction)
|
||||
import Servant.Server.Internal.RouteResult (RouteResult (..))
|
||||
import Servant.Server.Internal.Router (Router' (..))
|
||||
@@ -29,3 +31,8 @@ instance HasServer GetSendfile context where
|
||||
route _ _ action = RawRouter $ \env request respond ->
|
||||
runAction action env request respond $ \sendfile ->
|
||||
Route $ responseFile status200 sendfile.headers sendfile.path Nothing
|
||||
|
||||
data HTML
|
||||
|
||||
instance Accept HTML where
|
||||
contentType _ = "text" // "html" /: ("charset", "utf-8")
|
||||
|
||||
Reference in New Issue
Block a user