开发者

http PUT request with http-enumerator

I would like to use the http-enumerator package to perform not only GET/POST but also PUT.

http-enumerator:

http://hackage.haskell.org/package/http-enumerator

http://hackage.haskell.org/packages/archive/http-enumerator/0.6.5/doc/html/Network-HTTP-Enumerator.html

*) my first step was to construct a Request and print it.

However I failed to write a proper Show function (error "No instance for Show .. arising from a use of print").

*) next I think I have to use the function "httpLbs :: MonadIO m => Request m -> Manager -> m Response" to get the Response.

for people who search and need that info t开发者_开发百科oo: haskell, REST or restful request, http, rest api access


http-enumerator/http-conduit doesn't really care if you're using POST, PUT, DELETE, etc. You just need to change the method record of the Request datatype. Your best bet is to rely on OverloadedStrings for this, something like:

{-# LANGUAGE OverloadedStrings #-}
import Network.HTTP.Enumerator

main = do
    req <- parseUrl "http://www.example.com/put-url"
    withManager $ httpLbs req { method = "PUT" }

HTH

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜