File: gzip.hs

package info (click to toggle)
haskell-scotty 0.11.6%2Bdfsg-1
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 232 kB
  • sloc: haskell: 1,369; makefile: 6
file content (21 lines) | stat: -rwxr-xr-x 566 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
{-# LANGUAGE OverloadedStrings #-}
module Main (main) where

import Network.Wai.Middleware.RequestLogger
import Network.Wai.Middleware.Gzip

import Web.Scotty

main :: IO ()
main = scotty 3000 $ do
    -- Note that files are not gzip'd by the default settings.
    middleware $ gzip $ def { gzipFiles = GzipCompress }
    middleware logStdoutDev

    -- gzip a normal response
    get "/" $ text "It works"

    -- gzip a file response (note non-default gzip settings above)
    get "/afile" $ do
        setHeader "content-type" "text/plain"
        file "gzip.hs"