make QueryFlag more permissive
This commit is contained in:
parent
a9eeff14bd
commit
0802221789
2 changed files with 16 additions and 2 deletions
|
@ -133,11 +133,14 @@ instance (KnownSymbol sym, HasServer sublayout)
|
||||||
let querytext = parseQueryText $ rawQueryString request
|
let querytext = parseQueryText $ rawQueryString request
|
||||||
param = case lookup paramname querytext of
|
param = case lookup paramname querytext of
|
||||||
Just Nothing -> True -- param is there, with no value
|
Just Nothing -> True -- param is there, with no value
|
||||||
_ -> False -- param not in the query string or with a value
|
Just (Just v) -> examine v -- param with a value
|
||||||
|
Nothing -> False -- param not in the query string
|
||||||
|
|
||||||
route (Proxy :: Proxy sublayout) (subserver param) request respond
|
route (Proxy :: Proxy sublayout) (subserver param) request respond
|
||||||
|
|
||||||
where paramname = cs $ symbolVal (Proxy :: Proxy sym)
|
where paramname = cs $ symbolVal (Proxy :: Proxy sym)
|
||||||
|
examine v | v == "true" || v == "1" || v == "" = True
|
||||||
|
| otherwise = False
|
||||||
|
|
||||||
instance (KnownSymbol sym, HasClient sublayout)
|
instance (KnownSymbol sym, HasClient sublayout)
|
||||||
=> HasClient (QueryFlag sym :> sublayout) where
|
=> HasClient (QueryFlag sym :> sublayout) where
|
||||||
|
|
|
@ -178,6 +178,17 @@ queryParamSpec = do
|
||||||
name = "ALICE"
|
name = "ALICE"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let params3' = "?capitalize="
|
||||||
|
response3' <- Network.Wai.Test.request defaultRequest{
|
||||||
|
rawQueryString = params3',
|
||||||
|
queryString = parseQuery params3',
|
||||||
|
pathInfo = ["b"]
|
||||||
|
}
|
||||||
|
liftIO $
|
||||||
|
decode' (simpleBody response3') `shouldBe` Just alice{
|
||||||
|
name = "ALICE"
|
||||||
|
}
|
||||||
|
|
||||||
type PostApi = ReqBody Person :> Post Integer
|
type PostApi = ReqBody Person :> Post Integer
|
||||||
postApi :: Proxy PostApi
|
postApi :: Proxy PostApi
|
||||||
postApi = Proxy
|
postApi = Proxy
|
||||||
|
|
Loading…
Add table
Reference in a new issue