@@ -130,19 +130,24 @@ instance (Fetch api, KnownSymbol path) => Fetch (path :> api) where
130
130
options_ :: FetchOptions
131
131
options_ = options & currentPath %~ (<> ms " /" <> path)
132
132
-----------------------------------------------------------------------------
133
- instance (Show a , Fetch api , KnownSymbol path ) => Fetch (Capture path a :> api ) where
133
+ instance (ToHttpApiData a , Fetch api , KnownSymbol path ) => Fetch (Capture path a :> api ) where
134
134
type ToFetch (Capture path a :> api ) = a -> ToFetch api
135
135
fetchWith Proxy options arg = fetchWith (Proxy @ api ) options_
136
136
where
137
137
options_ :: FetchOptions
138
- options_ = options & currentPath %~ (<> ms " /" <> ms (show arg))
138
+ options_ = options & currentPath %~ (<> ms " /" <> ms (toEncodedUrlPiece arg))
139
139
-----------------------------------------------------------------------------
140
- instance (Show a , Fetch api , KnownSymbol name ) => Fetch (QueryParam name a :> api ) where
140
+ instance (ToHttpApiData a , Fetch api , KnownSymbol name ) => Fetch (QueryParam name a :> api ) where
141
141
type ToFetch (QueryParam name a :> api ) = a -> ToFetch api
142
142
fetchWith Proxy options arg = fetchWith (Proxy @ api ) options_
143
143
where
144
+ #if MIN_VERSION_http_api_data(0,5,1)
145
+ enc = toEncodedQueryParam
146
+ #else
147
+ enc = toEncodedUrlPiece
148
+ #endif
144
149
options_ :: FetchOptions
145
- options_ = options & queryParams <>~ [(ms " /" , ms (show arg))]
150
+ options_ = options & queryParams <>~ [(ms " /" , ms (enc arg))]
146
151
-----------------------------------------------------------------------------
147
152
instance (Fetch api , KnownSymbol name ) => Fetch (QueryFlag name :> api ) where
148
153
type ToFetch (QueryFlag name :> api ) = Bool -> ToFetch api
0 commit comments