@@ -130,19 +130,24 @@ instance (Fetch api, KnownSymbol path) => Fetch (path :> api) where
130130 options_ :: FetchOptions
131131 options_ = options & currentPath %~ (<> ms " /" <> path)
132132-----------------------------------------------------------------------------
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
134134 type ToFetch (Capture path a :> api ) = a -> ToFetch api
135135 fetchWith Proxy options arg = fetchWith (Proxy @ api ) options_
136136 where
137137 options_ :: FetchOptions
138- options_ = options & currentPath %~ (<> ms " /" <> ms (show arg))
138+ options_ = options & currentPath %~ (<> ms " /" <> ms (toEncodedUrlPiece arg))
139139-----------------------------------------------------------------------------
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
141141 type ToFetch (QueryParam name a :> api ) = a -> ToFetch api
142142 fetchWith Proxy options arg = fetchWith (Proxy @ api ) options_
143143 where
144+ #if MIN_VERSION_http_api_data(0,5,1)
145+ enc = toEncodedQueryParam
146+ #else
147+ enc = toEncodedUrlPiece
148+ #endif
144149 options_ :: FetchOptions
145- options_ = options & queryParams <>~ [(ms " /" , ms (show arg))]
150+ options_ = options & queryParams <>~ [(ms " /" , ms (enc arg))]
146151-----------------------------------------------------------------------------
147152instance (Fetch api , KnownSymbol name ) => Fetch (QueryFlag name :> api ) where
148153 type ToFetch (QueryFlag name :> api ) = Bool -> ToFetch api
0 commit comments