Declared query string parameters are always sent in requests, even when no value is assigned to them (?name). The server handles a missing query parameter, and a query parameter with no value the same, but to be consistent with the documentation ("If you give Nothing, nothing will be added to the query string.") I made a small change to avoid sending empty query parameters. Also the value and req' parameters were flipped in the lambda in the QueryParams case.

This commit is contained in:
Daniel Larsson 2015-01-01 15:14:07 +01:00
parent fbc012c348
commit 83afdcb96b

View file

@ -210,7 +210,7 @@ instance (KnownSymbol sym, ToText a, HasClient sublayout)
-- if mparam = Nothing, we don't add it to the query string
clientWithRoute Proxy req mparam =
clientWithRoute (Proxy :: Proxy sublayout) $
appendToQueryString pname mparamText req
maybe req (flip (appendToQueryString pname) req . Just) mparamText
where pname = cs pname'
pname' = symbolVal (Proxy :: Proxy sym)
@ -251,7 +251,7 @@ instance (KnownSymbol sym, ToText a, HasClient sublayout)
clientWithRoute Proxy req paramlist =
clientWithRoute (Proxy :: Proxy sublayout) $
foldl' (\ value req' -> appendToQueryString pname req' value) req paramlist'
foldl' (\ req' -> maybe req' (flip (appendToQueryString pname) req' . Just)) req paramlist'
where pname = cs pname'
pname' = symbolVal (Proxy :: Proxy sym)