packages feed

servant-matrix-param 0.3.2 → 0.3.3

raw patch · 3 files changed

+32/−8 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

servant-matrix-param.cabal view
@@ -1,5 +1,5 @@ name:           servant-matrix-param-version:        0.3.2+version:        0.3.3 synopsis:       Matrix parameter combinator for servant description:    Matrix parameter combinator for servant category:       Web
src/Servant/MatrixParam/Client/Internal.hs view
@@ -72,6 +72,25 @@       key = symbolVal (Proxy :: Proxy k)  instance+  ( HasClient (WMP rest :> api)+  , KnownSymbol k+  ) => HasClient (WMP (MatrixFlag k ': rest) :> api) where++  type Client (WMP (MatrixFlag k ': rest) :> api)+    = Bool -> Client (WMP rest :> api)++  clientWithRoute Proxy req flag+    | flag = clientWithRoute nextProxy+        req { reqPath = reqPath req ++ ";" ++ key }+    | otherwise = clientWithRoute nextProxy req+    where+      nextProxy :: Proxy (WMP rest :> api)+      nextProxy = Proxy++      key :: String+      key = symbolVal (Proxy :: Proxy k)++instance   ( HasClient api   ) => HasClient (WMP '[] :> api) where 
test/Servant/MatrixParam/ClientSpec.hs view
@@ -48,20 +48,23 @@       cliB Nothing Nothing `hasRequestPath` "/b"      it "can be combined with captures" $ do-      cliC 5 (Just 3) Nothing `hasRequestPath` "/5;foo=3"+      cliC 5 (Just 3) False `hasRequestPath` "/5;foo=3" +    it "supports matrix flags" $ do+      cliC 5 (Just 3) True `hasRequestPath` "/5;foo=3;bool" + #if MIN_VERSION_servant_client(0,9,0)     it "generates paths that servant-server understands" $ do       testWithApplication (return $ serve api server) $ \port -> do         let res = (,,) <$> cliA (Just "There is a there there")                        <*> cliB (Just 1) (Just 2)-                       <*> cliC 5 (Just 1) (Just 2)+                       <*> cliC 5 (Just 1) True              url = BaseUrl Http "localhost" port ""         mgr' <- newManager defaultManagerSettings         runClientM res (ClientEnv mgr' url)-          `shouldReturn` Right ("There is a there there", "3", "8")+          `shouldReturn` Right ("There is a there there", "3", "6") #endif ------------------------------------------------------------------------------ -- API@@ -71,7 +74,7 @@        WithMatrixParams "a" '[MatrixParam "name" String] :> Get '[JSON] String   :<|> WithMatrixParams "b" '[MatrixParam "foo" Int, MatrixParam "bar" Int]          :> Get '[JSON] String-  :<|> CaptureWithMatrixParams "c" Int '[MatrixParam "foo" Int, MatrixParam "bar" Int]+  :<|> CaptureWithMatrixParams "c" Int '[MatrixParam "foo" Int, MatrixFlag "bool"]          :> Get '[JSON] String  api :: Proxy Api@@ -84,7 +87,9 @@   where     e1 name = return $ fromMaybe "" name     e2 foo bar = return . show $ fromMaybe 0 foo + fromMaybe 0 bar-    e3 int foo bar = return . show $ int + fromMaybe 0 foo + fromMaybe 0 bar+    e3 int foo bool+      | bool      = return . show $ int + fromMaybe 0 foo+      | otherwise = return "" #endif  ------------------------------------------------------------------------------@@ -131,10 +136,10 @@ #if MIN_VERSION_servant_client(0,9,0) cliA :: Maybe String -> ClientM String cliB :: Maybe Int -> Maybe Int -> ClientM String-cliC :: Int -> Maybe Int -> Maybe Int -> ClientM String+cliC :: Int -> Maybe Int -> Bool -> ClientM String #else cliA :: Maybe String -> Manager -> BaseUrl -> ClientM String cliB :: Maybe Int -> Maybe Int -> Manager -> BaseUrl -> ClientM String-cliC :: Int -> Maybe Int -> Maybe Int -> Manager -> BaseUrl -> ClientM String+cliC :: Int -> Maybe Int -> Bool -> Manager -> BaseUrl -> ClientM String #endif cliA :<|> cliB :<|> cliC = client api