Suppose I have this function performing a get request:
import Network.HTTP.Conduit
import qualified Data.ByteString.Char8 as C8
get :: String -> [(C8.ByteString, C8.ByteString)] -> IO (Response LC8.ByteString)
get url par = do
request <- parseUrl url
res <- withManager $ httpLbs $ createReq request
return res
where
createReq req =
req {
method = methodGet
, queryString = map (\(k, v) -> k ++ "&=" ++ v) par -- ????
}
I believe there must a simpler way to create a query string. My method both is not simple and wrong as it doesn't care about "?" and "&" (there must be "?" in the beggining and must not be "&" at the end). So how do I create a query string for a get request from [(C8.ByteString, C8.ByteString)]
? Moreover, (++) can't be used with ByteString. But I haven't found any example which is surprising.