Gzip support
This commit is contained in:
parent
87361faa32
commit
deef7c5839
3 changed files with 18 additions and 9 deletions
|
@ -4,10 +4,12 @@
|
||||||
-- import Lib
|
-- import Lib
|
||||||
import Data.Text.Lazy (Text)
|
import Data.Text.Lazy (Text)
|
||||||
import Network.Wai.Handler.Warp (Port)
|
import Network.Wai.Handler.Warp (Port)
|
||||||
|
import Network.Wai.Middleware.RequestLogger (logStdoutDev)
|
||||||
import Text.Blaze ((!))
|
import Text.Blaze ((!))
|
||||||
import Text.Blaze.Html.Renderer.Text (renderHtml)
|
import Text.Blaze.Html.Renderer.Text (renderHtml)
|
||||||
|
|
||||||
import Network.HTTP.Types
|
import Network.HTTP.Types
|
||||||
|
import Network.Wai.Middleware.Gzip
|
||||||
import Web.Scotty as S
|
import Web.Scotty as S
|
||||||
|
|
||||||
import qualified Control.Exception as E
|
import qualified Control.Exception as E
|
||||||
|
@ -56,6 +58,9 @@ main = do
|
||||||
|
|
||||||
let anyRoute = regex "^.*$"
|
let anyRoute = regex "^.*$"
|
||||||
scotty port $ do
|
scotty port $ do
|
||||||
|
|
||||||
|
middleware $ gzip $ def { gzipFiles = GzipCompress }
|
||||||
|
middleware logStdoutDev
|
||||||
|
|
||||||
-- GET requests
|
-- GET requests
|
||||||
get "/" $ do
|
get "/" $ do
|
||||||
|
|
|
@ -33,6 +33,7 @@ library
|
||||||
, http-types >=0.12.4 && <0.13
|
, http-types >=0.12.4 && <0.13
|
||||||
, scotty ==0.22.*
|
, scotty ==0.22.*
|
||||||
, text >=2.1.1 && <2.2
|
, text >=2.1.1 && <2.2
|
||||||
|
, wai-extra >=3.1.16 && <3.2
|
||||||
, warp >=3.4.7 && <3.5
|
, warp >=3.4.7 && <3.5
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
|
||||||
|
@ -54,6 +55,7 @@ executable hs-server-exe
|
||||||
, http-types >=0.12.4 && <0.13
|
, http-types >=0.12.4 && <0.13
|
||||||
, scotty ==0.22.*
|
, scotty ==0.22.*
|
||||||
, text >=2.1.1 && <2.2
|
, text >=2.1.1 && <2.2
|
||||||
|
, wai-extra >=3.1.16 && <3.2
|
||||||
, warp >=3.4.7 && <3.5
|
, warp >=3.4.7 && <3.5
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
|
||||||
|
@ -76,5 +78,6 @@ test-suite hs-server-test
|
||||||
, http-types >=0.12.4 && <0.13
|
, http-types >=0.12.4 && <0.13
|
||||||
, scotty ==0.22.*
|
, scotty ==0.22.*
|
||||||
, text >=2.1.1 && <2.2
|
, text >=2.1.1 && <2.2
|
||||||
|
, wai-extra >=3.1.16 && <3.2
|
||||||
, warp >=3.4.7 && <3.5
|
, warp >=3.4.7 && <3.5
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
|
|
@ -19,14 +19,15 @@ extra-source-files:
|
||||||
description: Please see README.md
|
description: Please see README.md
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
- base >= 4.19.2 && < 4.20
|
- base >= 4.19.2 && < 4.20
|
||||||
- blaze-html >= 0.9.2 && < 0.10
|
- blaze-html >= 0.9.2 && < 0.10
|
||||||
- blaze-markup >= 0.8.3 && < 0.9
|
- blaze-markup >= 0.8.3 && < 0.9
|
||||||
- directory >= 1.3.8 && < 1.4
|
- directory >= 1.3.8 && < 1.4
|
||||||
- http-types >= 0.12.4 && < 0.13
|
- http-types >= 0.12.4 && < 0.13
|
||||||
- scotty >= 0.22 && < 0.23
|
- scotty >= 0.22 && < 0.23
|
||||||
- text >= 2.1.1 && < 2.2
|
- text >= 2.1.1 && < 2.2
|
||||||
- warp >= 3.4.7 && < 3.5
|
- wai-extra >= 3.1.16 && < 3.2
|
||||||
|
- warp >= 3.4.7 && < 3.5
|
||||||
|
|
||||||
ghc-options:
|
ghc-options:
|
||||||
- -Wall
|
- -Wall
|
||||||
|
@ -40,7 +41,7 @@ ghc-options:
|
||||||
- -Wredundant-constraints
|
- -Wredundant-constraints
|
||||||
|
|
||||||
library:
|
library:
|
||||||
source-dirs: src
|
source-dirs: src
|
||||||
|
|
||||||
executables:
|
executables:
|
||||||
hs-server-exe:
|
hs-server-exe:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue