on master help sign in
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.
83afdcbDaniel Larsson
src/Servant/Client.hs+2−2
@@ -210,7 +210,7 @@ instance (KnownSymbol sym, ToText a, HasClient sublayout)
210 -- if mparam = Nothing, we don't add it to the query string
210 -- if mparam = Nothing, we don't add it to the query string
211 clientWithRoute Proxy req mparam =
211 clientWithRoute Proxy req mparam =
212 clientWithRoute (Proxy :: Proxy sublayout) $
212 clientWithRoute (Proxy :: Proxy sublayout) $
213− appendToQueryString pname mparamText req
213+ maybe req (flip (appendToQueryString pname) req . Just) mparamText
214
214
215 where pname = cs pname'
215 where pname = cs pname'
216 pname' = symbolVal (Proxy :: Proxy sym)
216 pname' = symbolVal (Proxy :: Proxy sym)
@@ -251,7 +251,7 @@ instance (KnownSymbol sym, ToText a, HasClient sublayout)
251
251
252 clientWithRoute Proxy req paramlist =
252 clientWithRoute Proxy req paramlist =
253 clientWithRoute (Proxy :: Proxy sublayout) $
253 clientWithRoute (Proxy :: Proxy sublayout) $
254− foldl' (\ value req' -> appendToQueryString pname req' value) req paramlist'
254+ foldl' (\ req' -> maybe req' (flip (appendToQueryString pname) req' . Just)) req paramlist'
255
255
256 where pname = cs pname'
256 where pname = cs pname'
257 pname' = symbolVal (Proxy :: Proxy sym)
257 pname' = symbolVal (Proxy :: Proxy sym)