@@ -27,6 +27,7 @@ type Api =
2727 :<|> "capture" :> Capture "name" String :> Get Person
2828 :<|> "body" :> ReqBody Person :> Post Person
2929 :<|> "param" :> QueryParam "name" String :> Get Person
30+ :<|> "params" :> QueryParams "names" String :> Get [Person]
3031api :: Proxy Api
3132api = Proxy
3233
@@ -39,6 +40,7 @@ server = serve api (
3940 Just "alice" -> return alice
4041 Just name -> left (400, name ++ " not found")
4142 Nothing -> left (400, "missing parameter"))
43+ :<|> (\ names -> return (zipWith Person names [0..]))
4244 )
4345
4446withServer :: (URIAuth -> IO a) -> IO a
@@ -48,7 +50,13 @@ getGet :: URIAuth -> EitherT String IO Person
4850getCapture :: String -> URIAuth -> EitherT String IO Person
4951getBody :: Person -> URIAuth -> EitherT String IO Person
5052getQueryParam :: Maybe String -> URIAuth -> EitherT String IO Person
51−(getGet :<|> getCapture :<|> getBody :<|> getQueryParam) = client api
53+getQueryParams :: [String] -> URIAuth -> EitherT String IO [Person]
54+( getGet
55+ :<|> getCapture
56+ :<|> getBody
57+ :<|> getQueryParam
58+ :<|> getQueryParams)
59+ = client api
5260
5361spec :: Spec
5462spec = do
@@ -67,6 +75,11 @@ spec = do
6775 Left result <- runEitherT (getQueryParam (Just "bob") host)
6876 result `shouldContain` "bob not found"
6977
78+ it "Servant.API.QueryParam.QueryParams" $ withServer $ \ host -> do
79+ runEitherT (getQueryParams [] host) `shouldReturn` Right []
80+ runEitherT (getQueryParams ["alice", "bob"] host)
81+ `shouldReturn` Right [Person "alice" 0, Person "bob" 1]
82+
7083 context "client correctly handles error status codes" $ do
7184 let test :: WrappedApi -> Spec
7285 test (WrappedApi api) =