on master help sign in
Merge branch 'master' into gb-streaming
85cf8d1Gershom
.travis.yml+122−23
@@ -1,32 +1,131 @@
1+# This Travis job script has been generated by a script via
2+#
3+# make_travis_yml_2.hs '-f' '-o' '.travis.yml' 'cabal.project'
4+#
5+# For more information, see https://github.com/hvr/multi-ghc-travis
6+#
7+language: c
1sudo: false
8sudo: false
2−dist: trusty
3
9
4−language: c
10+git:
11+ submodules: false # whether to recursively clone submodules
12+
13+cache:
14+ directories:
15+ - $HOME/.cabal/packages
16+ - $HOME/.cabal/store
17+
18+before_cache:
19+ - rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log
20+ # remove files that are regenerated by 'cabal update'
21+ - rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index.*
22+ - rm -fv $HOME/.cabal/packages/hackage.haskell.org/*.json
23+ - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.cache
24+ - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar
25+ - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar.idx
5
26
6−env:
27+matrix:
7− - STACK_YAML=stack-ghc-7.8.4.yaml
28+ include:
8− - STACK_YAML=stack-ghc-7.10.3.yaml
29+ - compiler: "ghc-7.8.4"
9− - STACK_YAML=stack.yaml
30+ # env: TEST=--disable-tests BENCH=--disable-benchmarks
10− - STACK_YAML=stack-ghc-8.2.1.yaml
31+ addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-7.8.4], sources: [hvr-ghc]}}
32+ - compiler: "ghc-7.10.3"
33+ # env: TEST=--disable-tests BENCH=--disable-benchmarks
34+ addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-7.10.3], sources: [hvr-ghc]}}
35+ - compiler: "ghc-8.0.2"
36+ # env: TEST=--disable-tests BENCH=--disable-benchmarks
37+ addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.0.2], sources: [hvr-ghc]}}
38+ - compiler: "ghc-8.2.1"
39+ # env: TEST=--disable-tests BENCH=--disable-benchmarks
40+ addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.2.1], sources: [hvr-ghc]}}
11
41
12−addons:
42+before_install:
13− apt:
43+ - HC=${CC}
14− packages:
44+ - HCPKG=${HC/ghc/ghc-pkg}
15− - libgmp-dev
45+ - unset CC
46+ - PATH=/opt/ghc/bin:/opt/ghc-ppa-tools/bin:$PATH
16
47
17install:
48install:
18− - mkdir -p ~/.local/bin
49+ - cabal --version
19− - export PATH=$HOME/.local/bin:$PATH
50+ - echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
20− - travis_retry curl -L https://www.stackage.org/stack/linux-x86_64 | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'
51+ - BENCH=${BENCH---enable-benchmarks}
21− - stack --version
52+ - TEST=${TEST---enable-tests}
22− - stack setup --no-terminal
53+ - HADDOCK=${HADDOCK-true}
23− - (cd $HOME/.local/bin && wget https://zalora-public.s3.amazonaws.com/tinc && chmod +x tinc)
54+ - INSTALLED=${INSTALLED-true}
55+ - travis_retry cabal update -v
56+ - sed -i.bak 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config
57+ - rm -fv cabal.project.local
58+ - if [ -f "servant/configure.ac" ]; then
59+ (cd "servant"; autoreconf -i);
60+ fi
61+ - if [ -f "servant-client/configure.ac" ]; then
62+ (cd "servant-client"; autoreconf -i);
63+ fi
64+ - if [ -f "servant-client-core/configure.ac" ]; then
65+ (cd "servant-client-core"; autoreconf -i);
66+ fi
67+ - if [ -f "servant-docs/configure.ac" ]; then
68+ (cd "servant-docs"; autoreconf -i);
69+ fi
70+ - if [ -f "servant-foreign/configure.ac" ]; then
71+ (cd "servant-foreign"; autoreconf -i);
72+ fi
73+ - if [ -f "servant-server/configure.ac" ]; then
74+ (cd "servant-server"; autoreconf -i);
75+ fi
76+ - if [ -f "doc/tutorial/configure.ac" ]; then
77+ (cd "doc/tutorial"; autoreconf -i);
78+ fi
79+ - rm -f cabal.project.freeze
80+ - cabal new-build -w ${HC} ${TEST} ${BENCH} --project-file="cabal.project" --dep -j2 servant-server servant-client
81+ - cabal new-build -w ${HC} --disable-tests --disable-benchmarks --project-file="cabal.project" --dep -j2 servant-server servant-client
82+ - rm -rf "servant"/.ghc.environment.* "servant-client"/.ghc.environment.* "servant-client-core"/.ghc.environment.* "servant-docs"/.ghc.environment.* "servant-foreign"/.ghc.environment.* "servant-server"/.ghc.environment.* "doc/tutorial"/.ghc.environment.* "servant"/dist "servant-client"/dist "servant-client-core"/dist "servant-docs"/dist "servant-foreign"/dist "servant-server"/dist "doc/tutorial"/dist
83+ - DISTDIR=$(mktemp -d /tmp/dist-test.XXXX)
24
84
85+# Here starts the actual work to be performed for the package under test;
86+# any command which exits with a non-zero exit code causes the build to fail.
25script:
87script:
26− - if [ "$STACK_YAML" = "stack-ghc-8.2.1.yaml" ]; then HOMEMODULES="--ghc-options=-Wno-missing-home-modules"; fi
88+ # test that source-distributions can be generated
27− - if [ "$TRAVIS_EVENT_TYPE" = "cron" ] ; then ./scripts/ci-cron.sh ; else stack test $HOMEMODULES --ghc-options=-Werror --no-terminal ; fi
89+ - echo Packaging... && echo -en 'travis_fold:start:sdist\\r'
90+ - (cd "servant"; cabal sdist)
91+ - (cd "servant-client"; cabal sdist)
92+ - (cd "servant-client-core"; cabal sdist)
93+ - (cd "servant-docs"; cabal sdist)
94+ - (cd "servant-foreign"; cabal sdist)
95+ - (cd "servant-server"; cabal sdist)
96+ - (cd "doc/tutorial"; cabal sdist)
97+ - echo -en 'travis_fold:end:sdist\\r'
98+ - echo Unpacking... && echo -en 'travis_fold:start:unpack\\r'
99+ - mv "servant"/dist/servant-*.tar.gz "servant-client"/dist/servant-client-*.tar.gz "servant-client-core"/dist/servant-client-core-*.tar.gz "servant-docs"/dist/servant-docs-*.tar.gz "servant-foreign"/dist/servant-foreign-*.tar.gz "servant-server"/dist/servant-server-*.tar.gz "doc/tutorial"/dist/tutorial-*.tar.gz ${DISTDIR}/
100+ - cd ${DISTDIR}
101+ - find . -maxdepth 1 -name '*.tar.gz' -exec tar -xvf '{}' \;
102+ - "printf 'packages: servant-*/*.cabal servant-client-*/*.cabal servant-client-core-*/*.cabal servant-docs-*/*.cabal servant-foreign-*/*.cabal servant-server-*/*.cabal tutorial-*/*.cabal\n' > cabal.project"
103+ - echo -en 'travis_fold:end:unpack\\r'
104+ - echo Building... && echo -en 'travis_fold:start:build\\r'
105+ # this builds all libraries and executables (without tests/benchmarks)
106+ - cabal new-build -w ${HC} --disable-tests --disable-benchmarks all
107+ - echo -en 'travis_fold:end:build\\r'
28
108
29−cache:
109+ - echo Building with installed constraints for package in global-db... && echo -en 'travis_fold:start:build-installed\\r'
30− directories:
110+ # Build with installed constraints for packages in global-db
31− - $HOME/.tinc/cache
111+ - if $INSTALLED; then
32− - $HOME/.stack
112+ echo cabal new-build -w ${HC} --disable-tests --disable-benchmarks $(${HCPKG} list --global --simple-output --names-only | sed 's/\([a-zA-Z0-9-]\{1,\}\) */--constraint="\1 installed" /g') all | sh;
113+ else echo "Not building with installed constraints"; fi
114+ - echo -en 'travis_fold:end:build-installed\\r'
115+
116+ - echo Building with tests and benchmarks... && echo -en 'travis_fold:start:build-everything\\r'
117+ # build & run tests, build benchmarks
118+ - cabal new-build -w ${HC} ${TEST} ${BENCH} all
119+ - echo -en 'travis_fold:end:build-everything\\r'
120+ - echo Testing... && echo -en 'travis_fold:start:test\\r'
121+ - if [ "x$TEST" = "x--enable-tests" ]; then cabal new-test -w ${HC} ${TEST} all; fi
122+ - echo -en 'travis_fold:end:test\\r'
123+
124+ - echo Haddock... && echo -en 'travis_fold:start:haddock\\r'
125+ # haddock
126+ - rm -rf ./dist-newstyle
127+ - if $HADDOCK; then cabal new-haddock -w ${HC} --disable-tests --disable-benchmarks all; else echo "Skipping haddock generation";fi
128+
129+ - echo -en 'travis_fold:end:haddock\\r'
130+# REGENDATA ["-f","-o",".travis.yml","cabal.project"]
131+# EOF
cabal.project+1−2
@@ -1,5 +1,4 @@
1−packages:
1+packages: servant/
2− servant/
3 servant-client/
2 servant-client/
4 servant-client-core/
3 servant-client-core/
5 servant-docs/
4 servant-docs/
doc/tutorial/tutorial.cabal+12−1
@@ -8,6 +8,14 @@ author: Servant Contributors
8maintainer: haskell-servant-maintainers@googlegroups.com
8maintainer: haskell-servant-maintainers@googlegroups.com
9build-type: Simple
9build-type: Simple
10cabal-version: >=1.10
10cabal-version: >=1.10
11+tested-with:
12+ GHC==7.8.4
13+ GHC==7.10.3
14+ GHC==8.0.2
15+ GHC==8.2.1
16+extra-source-files:
17+ static/index.html
18+ static/ui.js
11
19
12library
20library
13 exposed-modules: ApiType
21 exposed-modules: ApiType
@@ -38,7 +46,8 @@ library
38 , string-conversions
46 , string-conversions
39 , bytestring
47 , bytestring
40 , attoparsec
48 , attoparsec
41− , mtl
49+ , mtl >=2.1 && <2.3
50+ , mtl-compat
42 , random
51 , random
43 , js-jquery
52 , js-jquery
44 , wai
53 , wai
@@ -57,6 +66,8 @@ test-suite spec
57 hs-source-dirs: test
66 hs-source-dirs: test
58 main-is: Spec.hs
67 main-is: Spec.hs
59 other-modules: JavascriptSpec
68 other-modules: JavascriptSpec
69+ build-tool-depends:
70+ hspec-discover:hspec-discover
60 build-depends: base == 4.*
71 build-depends: base == 4.*
61 , tutorial
72 , tutorial
62 , hspec
73 , hspec
servant-client-core/servant-client-core.cabal+9−1
@@ -18,6 +18,12 @@ extra-source-files:
18 include/*.h
18 include/*.h
19 CHANGELOG.md
19 CHANGELOG.md
20 README.md
20 README.md
21+tested-with:
22+ GHC==7.8.4
23+ GHC==7.10.3
24+ GHC==8.0.2
25+ GHC==8.2.1
26+
21source-repository head
27source-repository head
22 type: git
28 type: git
23 location: http://github.com/haskell-servant/servant.git
29 location: http://github.com/haskell-servant/servant.git
@@ -43,7 +49,7 @@ library
43 , generics-sop >= 0.1.0.0 && < 0.4
49 , generics-sop >= 0.1.0.0 && < 0.4
44 , http-api-data >= 0.3.6 && < 0.4
50 , http-api-data >= 0.3.6 && < 0.4
45 , http-media >= 0.6.2 && < 0.8
51 , http-media >= 0.6.2 && < 0.8
46− , http-types >= 0.8.6 && < 0.10
52+ , http-types >= 0.8.6 && < 0.11
47 , mtl >= 2.1 && < 2.3
53 , mtl >= 2.1 && < 2.3
48 , network-uri >= 2.6 && < 2.7
54 , network-uri >= 2.6 && < 2.7
49 , safe >= 0.3.9 && < 0.4
55 , safe >= 0.3.9 && < 0.4
@@ -70,5 +76,7 @@ test-suite spec
70 , servant-client-core
76 , servant-client-core
71 , hspec == 2.*
77 , hspec == 2.*
72 , QuickCheck >= 2.7 && < 2.11
78 , QuickCheck >= 2.7 && < 2.11
79+ build-tool-depends:
80+ hspec-discover:hspec-discover
73 other-modules:
81 other-modules:
74 Servant.Client.Core.Internal.BaseUrlSpec
82 Servant.Client.Core.Internal.BaseUrlSpec
servant-client/servant-client.cabal+8−2
@@ -16,7 +16,11 @@ copyright: 2014-2016 Zalora South East Asia Pte Ltd, 2016-2017 Servant
16category: Servant, Web
16category: Servant, Web
17build-type: Simple
17build-type: Simple
18cabal-version: >=1.10
18cabal-version: >=1.10
19−tested-with: GHC >= 7.8
19+tested-with:
20+ GHC==7.8.4
21+ GHC==7.10.3
22+ GHC==8.0.2
23+ GHC==8.2.1
20homepage: http://haskell-servant.readthedocs.org/
24homepage: http://haskell-servant.readthedocs.org/
21Bug-reports: http://github.com/haskell-servant/servant/issues
25Bug-reports: http://github.com/haskell-servant/servant/issues
22extra-source-files:
26extra-source-files:
@@ -41,7 +45,7 @@ library
41 , http-client >= 0.4.30 && < 0.6
45 , http-client >= 0.4.30 && < 0.6
42 , http-client-tls >= 0.2.2 && < 0.4
46 , http-client-tls >= 0.2.2 && < 0.4
43 , http-media >= 0.6.2 && < 0.8
47 , http-media >= 0.6.2 && < 0.8
44− , http-types >= 0.8.6 && < 0.10
48+ , http-types >= 0.8.6 && < 0.11
45 , exceptions >= 0.8 && < 0.9
49 , exceptions >= 0.8 && < 0.9
46 , monad-control >= 1.0.0.4 && < 1.1
50 , monad-control >= 1.0.0.4 && < 1.1
47 , mtl >= 2.1 && < 2.3
51 , mtl >= 2.1 && < 2.3
@@ -64,6 +68,8 @@ test-suite spec
64 default-language: Haskell2010
68 default-language: Haskell2010
65 hs-source-dirs: test
69 hs-source-dirs: test
66 main-is: Spec.hs
70 main-is: Spec.hs
71+ build-tool-depends:
72+ hspec-discover:hspec-discover
67 other-modules:
73 other-modules:
68 Servant.ClientSpec
74 Servant.ClientSpec
69 Servant.StreamSpec
75 Servant.StreamSpec
servant-docs/servant-docs.cabal+7−1
@@ -15,7 +15,11 @@ copyright: 2014-2016 Zalora South East Asia Pte Ltd, Servant Contribut
15category: Servant, Web
15category: Servant, Web
16build-type: Simple
16build-type: Simple
17cabal-version: >=1.10
17cabal-version: >=1.10
18−tested-with: GHC >= 7.8
18+tested-with:
19+ GHC==7.8.4
20+ GHC==7.10.3
21+ GHC==8.0.2
22+ GHC==8.2.1
19homepage: http://haskell-servant.readthedocs.org/
23homepage: http://haskell-servant.readthedocs.org/
20Bug-reports: http://github.com/haskell-servant/servant/issues
24Bug-reports: http://github.com/haskell-servant/servant/issues
21extra-source-files:
25extra-source-files:
@@ -75,6 +79,8 @@ test-suite spec
75 type: exitcode-stdio-1.0
79 type: exitcode-stdio-1.0
76 main-is: Spec.hs
80 main-is: Spec.hs
77 other-modules: Servant.DocsSpec
81 other-modules: Servant.DocsSpec
82+ build-tool-depends:
83+ hspec-discover:hspec-discover
78 hs-source-dirs: test
84 hs-source-dirs: test
79 ghc-options: -Wall
85 ghc-options: -Wall
80 build-depends:
86 build-depends:
servant-foreign/servant-foreign.cabal+8
@@ -22,6 +22,12 @@ extra-source-files:
22 CHANGELOG.md
22 CHANGELOG.md
23 README.md
23 README.md
24bug-reports: http://github.com/haskell-servant/servant/issues
24bug-reports: http://github.com/haskell-servant/servant/issues
25+tested-with:
26+ GHC==7.8.4
27+ GHC==7.10.3
28+ GHC==8.0.2
29+ GHC==8.2.1
30+
25source-repository head
31source-repository head
26 type: git
32 type: git
27 location: http://github.com/haskell-servant/servant.git
33 location: http://github.com/haskell-servant/servant.git
@@ -65,6 +71,8 @@ test-suite spec
65 include-dirs: include
71 include-dirs: include
66 main-is: Spec.hs
72 main-is: Spec.hs
67 other-modules: Servant.ForeignSpec
73 other-modules: Servant.ForeignSpec
74+ build-tool-depends:
75+ hspec-discover:hspec-discover
68 build-depends: base
76 build-depends: base
69 , hspec >= 2.1.8
77 , hspec >= 2.1.8
70 , servant
78 , servant
servant-server/servant-server.cabal+7−2
@@ -21,7 +21,11 @@ copyright: 2014-2016 Zalora South East Asia Pte Ltd, Servant Contribut
21category: Servant, Web
21category: Servant, Web
22build-type: Custom
22build-type: Custom
23cabal-version: >=1.10
23cabal-version: >=1.10
24−tested-with: GHC >= 7.8
24+tested-with:
25+ GHC==7.8.4
26+ GHC==7.10.3
27+ GHC==8.0.2
28+ GHC==8.2.1
25extra-source-files:
29extra-source-files:
26 include/*.h
30 include/*.h
27 CHANGELOG.md
31 CHANGELOG.md
@@ -60,7 +64,6 @@ library
60 , containers >= 0.5 && < 0.6
64 , containers >= 0.5 && < 0.6
61 , exceptions >= 0.8 && < 0.9
65 , exceptions >= 0.8 && < 0.9
62 , http-api-data >= 0.3 && < 0.4
66 , http-api-data >= 0.3 && < 0.4
63− , http-media >= 0.4 && < 0.8
64 , http-types >= 0.8 && < 0.10
67 , http-types >= 0.8 && < 0.10
65 , network-uri >= 2.6 && < 2.7
68 , network-uri >= 2.6 && < 2.7
66 , monad-control >= 1.0.0.4 && < 1.1
69 , monad-control >= 1.0.0.4 && < 1.1
@@ -121,6 +124,8 @@ test-suite spec
121 Servant.Server.UsingContextSpec.TestCombinators
124 Servant.Server.UsingContextSpec.TestCombinators
122 Servant.ServerSpec
125 Servant.ServerSpec
123 Servant.Utils.StaticFilesSpec
126 Servant.Utils.StaticFilesSpec
127+ build-tool-depends:
128+ hspec-discover:hspec-discover
124 build-depends:
129 build-depends:
125 base == 4.*
130 base == 4.*
126 , base-compat
131 , base-compat
servant-server/src/Servant/Server/Internal.hs+13−33
@@ -46,7 +46,7 @@ import GHC.TypeLits (KnownNat, KnownSymbol, natVal,
46import Network.HTTP.Types hiding (Header, ResponseHeaders)
46import Network.HTTP.Types hiding (Header, ResponseHeaders)
47import qualified Network.HTTP.Media as NHM
47import qualified Network.HTTP.Media as NHM
48import Network.Socket (SockAddr)
48import Network.Socket (SockAddr)
49−import Network.Wai (Application, Request, Response,
49+import Network.Wai (Application, Request,
50 httpVersion, isSecure,
50 httpVersion, isSecure,
51 lazyRequestBody,
51 lazyRequestBody,
52 rawQueryString, remoteHost,
52 rawQueryString, remoteHost,
@@ -208,16 +208,6 @@ allowedMethodHead method request = method == methodGet && requestMethod request
208allowedMethod :: Method -> Request -> Bool
208allowedMethod :: Method -> Request -> Bool
209allowedMethod method request = allowedMethodHead method request || requestMethod request == method
209allowedMethod method request = allowedMethodHead method request || requestMethod request == method
210
210
211−processMethodRouter :: Maybe (BL.ByteString, BL.ByteString) -> Status -> Method
212− -> Maybe [(HeaderName, B.ByteString)]
213− -> Request -> RouteResult Response
214−processMethodRouter handleA status method headers request = case handleA of
215− Nothing -> FailFatal err406 -- this should not happen (checked before), so we make it fatal if it does
216− Just (contentT, body) -> Route $ responseLBS status hdrs bdy
217− where
218− bdy = if allowedMethodHead method request then "" else body
219− hdrs = (hContentType, cs contentT) : (fromMaybe [] headers)
220−
221methodCheck :: Method -> Request -> DelayedIO ()
211methodCheck :: Method -> Request -> DelayedIO ()
222methodCheck method request
212methodCheck method request
223 | allowedMethod method request = return ()
213 | allowedMethod method request = return ()
@@ -236,33 +226,23 @@ acceptCheck proxy accH
236 | otherwise = delayedFail err406
226 | otherwise = delayedFail err406
237
227
238methodRouter :: (AllCTRender ctypes a)
228methodRouter :: (AllCTRender ctypes a)
229+ => (b -> ([(HeaderName, B.ByteString)], a))
239− => Method -> Proxy ctypes -> Status
230+ -> Method -> Proxy ctypes -> Status
240− -> Delayed env (Handler a)
231+ -> Delayed env (Handler b)
241 -> Router env
232 -> Router env
242−methodRouter method proxy status action = leafRouter route'
233+methodRouter splitHeaders method proxy status action = leafRouter route'
243 where
234 where
244 route' env request respond =
235 route' env request respond =
245 let accH = fromMaybe ct_wildcard $ lookup hAccept $ requestHeaders request
236 let accH = fromMaybe ct_wildcard $ lookup hAccept $ requestHeaders request
246 in runAction (action `addMethodCheck` methodCheck method request
237 in runAction (action `addMethodCheck` methodCheck method request
247 `addAcceptCheck` acceptCheck proxy accH
238 `addAcceptCheck` acceptCheck proxy accH
248 ) env request respond $ \ output -> do
239 ) env request respond $ \ output -> do
240+ let (headers, b) = splitHeaders output
249− let handleA = handleAcceptH proxy (AcceptHeader accH) output
241+ case handleAcceptH proxy (AcceptHeader accH) b of
250− processMethodRouter handleA status method Nothing request
242+ Nothing -> FailFatal err406 -- this should not happen (checked before), so we make it fatal if it does
251−
243+ Just (contentT, body) ->
252−methodRouterHeaders :: (GetHeaders (Headers h v), AllCTRender ctypes v)
244+ let bdy = if allowedMethodHead method request then "" else body
253− => Method -> Proxy ctypes -> Status
245+ in Route $ responseLBS status ((hContentType, cs contentT) : headers) bdy
254− -> Delayed env (Handler (Headers h v))
255− -> Router env
256−methodRouterHeaders method proxy status action = leafRouter route'
257− where
258− route' env request respond =
259− let accH = fromMaybe ct_wildcard $ lookup hAccept $ requestHeaders request
260− in runAction (action `addMethodCheck` methodCheck method request
261− `addAcceptCheck` acceptCheck proxy accH
262− ) env request respond $ \ output -> do
263− let headers = getHeaders output
264− handleA = handleAcceptH proxy (AcceptHeader accH) (getResponse output)
265− processMethodRouter handleA status method (Just headers) request
266
246
267instance OVERLAPPABLE_
247instance OVERLAPPABLE_
268 ( AllCTRender ctypes a, ReflectMethod method, KnownNat status
248 ( AllCTRender ctypes a, ReflectMethod method, KnownNat status
@@ -271,7 +251,7 @@ instance OVERLAPPABLE_
271 type ServerT (Verb method status ctypes a) m = m a
251 type ServerT (Verb method status ctypes a) m = m a
272 hoistServerWithContext _ _ nt s = nt s
252 hoistServerWithContext _ _ nt s = nt s
273
253
274− route Proxy _ = methodRouter method (Proxy :: Proxy ctypes) status
254+ route Proxy _ = methodRouter ([],) method (Proxy :: Proxy ctypes) status
275 where method = reflectMethod (Proxy :: Proxy method)
255 where method = reflectMethod (Proxy :: Proxy method)
276 status = toEnum . fromInteger $ natVal (Proxy :: Proxy status)
256 status = toEnum . fromInteger $ natVal (Proxy :: Proxy status)
277
257
@@ -283,7 +263,7 @@ instance OVERLAPPING_
283 type ServerT (Verb method status ctypes (Headers h a)) m = m (Headers h a)
263 type ServerT (Verb method status ctypes (Headers h a)) m = m (Headers h a)
284 hoistServerWithContext _ _ nt s = nt s
264 hoistServerWithContext _ _ nt s = nt s
285
265
286− route Proxy _ = methodRouterHeaders method (Proxy :: Proxy ctypes) status
266+ route Proxy _ = methodRouter (\x -> (getHeaders x, getResponse x)) method (Proxy :: Proxy ctypes) status
287 where method = reflectMethod (Proxy :: Proxy method)
267 where method = reflectMethod (Proxy :: Proxy method)
288 status = toEnum . fromInteger $ natVal (Proxy :: Proxy status)
268 status = toEnum . fromInteger $ natVal (Proxy :: Proxy status)
289
269
servant-server/test/Servant/ServerSpec.hs+11−2
@@ -33,7 +33,11 @@ import Network.HTTP.Types (Status (..), hAccept, hContentType,
33 methodDelete, methodGet,
33 methodDelete, methodGet,
34 methodHead, methodPatch,
34 methodHead, methodPatch,
35 methodPost, methodPut, ok200,
35 methodPost, methodPut, ok200,
36+#if MIN_VERSION_http_types(0,10,0)
37+ imATeapot418,
38+#else
36 imATeaPot418,
39 imATeaPot418,
40+#endif
37 parseQuery)
41 parseQuery)
38import Network.Wai (Application, Request, requestHeaders, pathInfo,
42import Network.Wai (Application, Request, requestHeaders, pathInfo,
39 queryString, rawQueryString,
43 queryString, rawQueryString,
@@ -70,6 +74,11 @@ import Servant.Server.Experimental.Auth
70import Servant.Server.Internal.Context
74import Servant.Server.Internal.Context
71 (NamedContext(..))
75 (NamedContext(..))
72
76
77+#if !MIN_VERSION_http_types(0,10,0)
78+imATeapot418 :: Status
79+imATeapot418 = imATeaPot418
80+#endif
81+
73-- * comprehensive api test
82-- * comprehensive api test
74
83
75-- This declaration simply checks that all instances are in place.
84-- This declaration simply checks that all instances are in place.
@@ -662,7 +671,7 @@ basicAuthApi = Proxy
662basicAuthServer :: Server BasicAuthAPI
671basicAuthServer :: Server BasicAuthAPI
663basicAuthServer =
672basicAuthServer =
664 const (return jerry) :<|>
673 const (return jerry) :<|>
665− (Tagged $ \ _ respond -> respond $ responseLBS imATeaPot418 [] "")
674+ (Tagged $ \ _ respond -> respond $ responseLBS imATeapot418 [] "")
666
675
667basicAuthContext :: Context '[ BasicAuthCheck () ]
676basicAuthContext :: Context '[ BasicAuthCheck () ]
668basicAuthContext =
677basicAuthContext =
@@ -707,7 +716,7 @@ genAuthApi = Proxy
707
716
708genAuthServer :: Server GenAuthAPI
717genAuthServer :: Server GenAuthAPI
709genAuthServer = const (return tweety)
718genAuthServer = const (return tweety)
710− :<|> (Tagged $ \ _ respond -> respond $ responseLBS imATeaPot418 [] "")
719+ :<|> (Tagged $ \ _ respond -> respond $ responseLBS imATeapot418 [] "")
711
720
712type instance AuthServerData (AuthProtect "auth") = ()
721type instance AuthServerData (AuthProtect "auth") = ()
713
722
servant/servant.cabal+8−2
@@ -17,7 +17,11 @@ copyright: 2014-2016 Zalora South East Asia Pte Ltd, Servant Contribut
17category: Servant, Web
17category: Servant, Web
18build-type: Custom
18build-type: Custom
19cabal-version: >=1.10
19cabal-version: >=1.10
20−tested-with: GHC >= 7.8
20+tested-with:
21+ GHC==7.8.4
22+ GHC==7.10.3
23+ GHC==8.0.2
24+ GHC==8.2.1
21extra-source-files:
25extra-source-files:
22 include/*.h
26 include/*.h
23 CHANGELOG.md
27 CHANGELOG.md
@@ -67,7 +71,7 @@ library
67 , case-insensitive >= 1.2 && < 1.3
71 , case-insensitive >= 1.2 && < 1.3
68 , http-api-data >= 0.3 && < 0.4
72 , http-api-data >= 0.3 && < 0.4
69 , http-media >= 0.4 && < 0.8
73 , http-media >= 0.4 && < 0.8
70− , http-types >= 0.8 && < 0.10
74+ , http-types >= 0.8 && < 0.11
71 , natural-transformation >= 0.4 && < 0.5
75 , natural-transformation >= 0.4 && < 0.5
72 , mtl >= 2.0 && < 2.3
76 , mtl >= 2.0 && < 2.3
73 , mmorph >= 1 && < 1.2
77 , mmorph >= 1 && < 1.2
@@ -119,6 +123,8 @@ test-suite spec
119 Servant.API.ResponseHeadersSpec
123 Servant.API.ResponseHeadersSpec
120 Servant.Utils.LinksSpec
124 Servant.Utils.LinksSpec
121 Servant.Utils.EnterSpec
125 Servant.Utils.EnterSpec
126+ build-tool-depends:
127+ hspec-discover:hspec-discover
122 build-depends:
128 build-depends:
123 base == 4.*
129 base == 4.*
124 , base-compat
130 , base-compat
stack.yaml+2−1
@@ -10,7 +10,8 @@ packages:
10extra-deps:
10extra-deps:
11- aeson-1.2.0.0
11- aeson-1.2.0.0
12- attoparsec-iso8601-1.0.0.0
12- attoparsec-iso8601-1.0.0.0
13−- http-media-0.7.0
14- cabal-doctest-1.0.2
13- cabal-doctest-1.0.2
15- http-api-data-0.3.7
14- http-api-data-0.3.7
15+- http-media-0.7.0
16+- http-types-0.10
16- servant-js-0.9.3
17- servant-js-0.9.3