Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use toEncodedQueryParam for QueryParam #1628

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions servant-client-core/src/Servant/Client/Core/Request.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import Network.HTTP.Types
(Header, HeaderName, HttpVersion (..), Method, QueryItem,
http11, methodGet)
import Servant.API
(ToHttpApiData, toEncodedUrlPiece, toHeader, SourceIO)
(ToHttpApiData, toEncodedQueryParam, toHeader, SourceIO)

import Servant.Client.Core.Internal (mediaTypeRnf)

Expand Down Expand Up @@ -165,7 +165,7 @@ appendToQueryString pname pvalue req
-- | Encode a query parameter value.
--
encodeQueryParamValue :: ToHttpApiData a => a -> BS.ByteString
encodeQueryParamValue = LBS.toStrict . Builder.toLazyByteString . toEncodedUrlPiece
encodeQueryParamValue = LBS.toStrict . Builder.toLazyByteString . toEncodedQueryParam

-- | Add header to the request being constructed.
--
Expand Down
4 changes: 2 additions & 2 deletions servant-client/test/Servant/ClientTestUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,8 @@ pathGen = fmap NonEmpty path
newtype UrlEncodedByteString = UrlEncodedByteString { unUrlEncodedByteString :: ByteString }

instance ToHttpApiData UrlEncodedByteString where
toEncodedUrlPiece = byteString . HTTP.urlEncode True . unUrlEncodedByteString
toUrlPiece = decodeUtf8 . HTTP.urlEncode True . unUrlEncodedByteString
toEncodedQueryParam = byteString . HTTP.urlEncode True . unUrlEncodedByteString
toQueryParam = decodeUtf8 . HTTP.urlEncode True . unUrlEncodedByteString

instance FromHttpApiData UrlEncodedByteString where
parseUrlPiece = pure . UrlEncodedByteString . HTTP.urlDecode True . encodeUtf8
Expand Down
2 changes: 1 addition & 1 deletion servant-server/servant-server.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ library
-- strict dependency as we re-export 'servant' things.
build-depends:
servant >= 0.19 && < 0.20
, http-api-data >= 0.4.1 && < 0.5.1
, http-api-data >= 0.5.1 && < 0.6

-- Other dependencies: Lower bound around what is in the latest Stackage LTS.
-- Here can be exceptions if we really need features from the newer versions.
Expand Down
2 changes: 1 addition & 1 deletion servant/servant.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ library
-- We depend (heavily) on the API of these packages:
-- i.e. re-export, or allow using without direct dependency
build-depends:
http-api-data >= 0.4.1 && < 0.5.1
http-api-data >= 0.5.1 && < 0.6
, singleton-bool >= 0.1.4 && < 0.1.7

-- Other dependencies: Lower bound around what is in the latest Stackage LTS.
Expand Down
5 changes: 4 additions & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resolver: lts-18.5
resolver: lts-19.30
packages:
- servant-client-core/
- servant-client/
Expand All @@ -18,3 +18,6 @@ packages:

extra-deps:
- hspec-wai-0.10.1
- github: fizruk/http-api-data
commit: 5408b078d1ee960309a9fc6141b7e14bc903b3a0
- attoparsec-iso8601-1.1.0.0
28 changes: 23 additions & 5 deletions stack.yaml.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,31 @@ packages:
- completed:
hackage: hspec-wai-0.10.1@sha256:56dd9ec1d56f47ef1946f71f7cbf070e4c285f718cac1b158400ae5e7172ef47,2290
pantry-tree:
size: 809
sha256: 17af1c2e709cd84bfda066b9ebb04cdde7f92660c51a1f7401a1e9f766524e93
size: 809
original:
hackage: hspec-wai-0.10.1
- completed:
name: http-api-data
pantry-tree:
sha256: 85b13f87bc1a47a9107dcf9406da94619c13a7040585ffd337a1e89d2aab4e0d
size: 1168
sha256: 3712b601120361b2977cafb210647c365923c57d9f3fedd4b41874813e36e671
size: 24310
url: https://github.com/fizruk/http-api-data/archive/5408b078d1ee960309a9fc6141b7e14bc903b3a0.tar.gz
version: 0.5.1
original:
url: https://github.com/fizruk/http-api-data/archive/5408b078d1ee960309a9fc6141b7e14bc903b3a0.tar.gz
- completed:
hackage: attoparsec-iso8601-1.1.0.0@sha256:29d590f21adc4112973ad5e874d095f8b403b886932fe7e15567b239f5483539,1370
pantry-tree:
sha256: 7eddd7d3bd0f3d51a3b0fe8284ed996bc2bf83effc8cf6afce360e5f0e54fbe5
size: 361
original:
hackage: attoparsec-iso8601-1.1.0.0
snapshots:
- completed:
size: 585817
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/18/5.yaml
sha256: 22d24d0dacad9c1450b9a174c28d203f9bb482a2a8da9710a2f2a9f4afee2887
original: lts-18.5
sha256: 9a74d76d250a455d9cd11e74f157e087787fa9aa3c4264e69c94703d1e71aede
size: 619200
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/19/30.yaml
original: lts-19.30