on master help sign in
This test case reproduces servant issue #3.
commitaaf448f3fed6a7d9725df5fe66189ae41db84b97 authorAlp Mestanogullari <alpmestan@gmail.com> dateThu 1 Jan 2015, 21:21 (12 years ago) parentdf5c8d977aed79
2 files changed+12−2
src/Servant/Server.hs+3 test/Servant/ServerSpec.hs+9−2
src/Servant/Server.hs+3
@@ -29,6 +29,9 @@ import Servant.Server.Internal
2929-- > where listAllBooks = ...
3030-- > postBook book = ...
3131-- >
32+-- > myApi :: Proxy MyApi
33+-- > myApi = Proxy
34+-- >
3235-- > app :: Application
3336-- > app = serve myApi server
3437-- >
test/Servant/ServerSpec.hs+9−2
@@ -189,19 +189,26 @@ queryParamSpec = do
189189 name = "ALICE"
190190 }
191191
192−type PostApi = ReqBody Person :> Post Integer
192+type PostApi =
193+ ReqBody Person :> Post Integer
194+ :<|> "bla" :> ReqBody Person :> Post Integer
193195postApi :: Proxy PostApi
194196postApi = Proxy
195197
196198postSpec :: Spec
197199postSpec = do
198200 describe "Servant.API.Post and .ReqBody" $ do
199− with (return (serve postApi (return . age))) $ do
201+ with (return (serve postApi (return . age :<|> return . age))) $ do
200202 it "allows to POST a Person" $ do
201203 post "/" (encode alice) `shouldRespondWith` "42"{
202204 matchStatus = 201
203205 }
204206
207+ it "allows alternative routes if all have request bodies" $ do
208+ post "/bla" (encode alice) `shouldRespondWith` "42"{
209+ matchStatus = 201
210+ }
211+
205212 it "correctly rejects invalid request bodies with status 400" $ do
206213 post "/" "some invalid body" `shouldRespondWith` 400
207214