apiary 0.17.0 → 0.17.1
raw patch · 4 files changed
+31/−17 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +8/−0
- apiary.cabal +1/−1
- src/Control/Monad/Apiary/Filter.hs +5/−2
- test/Application.hs +17/−14
CHANGELOG.md view
@@ -1,3 +1,11 @@+# 0.17.1+* relax switchQuery.++ old new+ key True True+ key=true False True+ key=false False False+ # 0.17.0 * fix not accept in multi Accept header. * add greedy path capture('\*\*').
apiary.cabal view
@@ -1,5 +1,5 @@ name: apiary-version: 0.17.0+version: 0.17.1 synopsis: Simple and type safe web framework that can be automatically generate API documentation. description: Simple and type safe web framework that can be automatically generate API documentation.
src/Control/Monad/Apiary/Filter.hs view
@@ -70,7 +70,6 @@ import Data.Proxy import Data.Apiary.SList import Data.String-import Data.Maybe import Data.Apiary.Param import Data.Apiary.Document@@ -246,9 +245,13 @@ switchQuery :: Monad actM => QueryKey -> ApiaryT exts (Bool ': prms) actM m () -> ApiaryT exts prms actM m () switchQuery QueryKey{..} = focus doc $ \l -> do r <- getRequest- return $ (not . null $ filter (\(k,v) -> isNothing v && queryKey == k) (queryString r)) ::: l+ return $ (not . null $ filter (\(k,v) -> queryKey == k && checkValue v) (queryString r)) ::: l where doc = DocQuery queryKey (StrategyRep "Switch") NoValue queryDesc+ checkValue Nothing = True+ checkValue v = case readQuery v :: Maybe Bool of+ Just True -> True+ _ -> False --------------------------------------------------------------------------------
test/Application.hs view
@@ -113,20 +113,7 @@ ] ---------------------------------------------------------------------------------anyFilterApp :: Application-anyFilterApp = runApp $ [capture|/test|] . anyPath . action $ do- contentType "text/plain"- bytes "hello" -anyFilterTest :: Test-anyFilterTest = testGroup "anyPath" $ map ($ anyFilterApp)- [ testReq "GET /" . assert404- , testReq "GET /test" . assertPlain200 "hello"- , testReq "POST /test/foo" . assertPlain200 "hello"- ]----------------------------------------------------------------------------------- restFilterApp :: Application restFilterApp = runApp $ do [capture|/test/**|] . action $ \l -> contentType "text/plain" >> showing l@@ -259,7 +246,23 @@ , testReq "GET /?foo=12&foo=b" . assertPlain200 "foo String [\"12\",\"b\"]" ] +switchQueryApp :: Application+switchQueryApp = runApp $ do+ switchQuery "foo" . switchQuery "bar" . action $ \f b ->+ contentType "text/plain" >> showing f >> showing b +switchQueryTest :: Test+switchQueryTest = testGroup "switch" $ map ($ switchQueryApp)+ [ testReq "GET /" . assertPlain200 "FalseFalse"+ , testReq "GET /?foo" . assertPlain200 "TrueFalse"+ , testReq "GET /?foo&bar" . assertPlain200 "TrueTrue"+ , testReq "GET /?foo=true" . assertPlain200 "TrueFalse"+ , testReq "GET /?foo=false" . assertPlain200 "FalseFalse"+ , testReq "GET /?foo=false&bar=true" . assertPlain200 "FalseTrue"+ , testReq "GET /?foo&bar=true" . assertPlain200 "TrueTrue"+ , testReq "GET /?foo=1&bar=0" . assertPlain200 "TrueFalse"+ ]+ queryTest :: Test queryTest = testGroup "query" [ queryFirstTest@@ -269,6 +272,7 @@ , queryCheckTest , queryManyTest , querySomeTest+ , switchQueryTest ] --------------------------------------------------------------------------------@@ -334,7 +338,6 @@ , methodFilterTest , httpVersionTest , rootFilterTest- , anyFilterTest , restFilterTest , captureTest , queryTest