module Haskus.Web.Response
( sendJson
, sendJS
, sendPNG
, sendJPG
, sendData
, sendBinary
, sendLazyJson
, sendLazyData
)
where
import qualified Data.ByteString as BS
import qualified Data.ByteString.Lazy as LBS
import qualified Data.ByteString.Char8 as BS8
import Haskus.Web.Server
sendJson :: BS.ByteString -> ServerPartT IO Response
sendJson = sendData "application/json"
sendJS :: BS.ByteString -> ServerPartT IO Response
sendJS = sendData "text/javascript"
sendBinary :: BS.ByteString -> ServerPartT IO Response
sendBinary = sendData "application/octet-stream"
sendPNG :: BS.ByteString -> ServerPartT IO Response
sendPNG = sendData "image/png"
sendJPG :: BS.ByteString -> ServerPartT IO Response
sendJPG = sendData "image/jpg"
sendData :: String -> BS.ByteString -> ServerPartT IO Response
sendData mime dat = ok (toResponseBS (BS8.pack mime) (LBS.fromStrict dat))
sendLazyJson :: LBS.ByteString -> ServerPartT IO Response
sendLazyJson = sendLazyData "application/json"
sendLazyData :: String -> LBS.ByteString -> ServerPartT IO Response
sendLazyData mime dat = ok (toResponseBS (BS8.pack mime) dat)