on master help sign in
Add usage example for reqBodyMultipart (#8)
commit8e82c816aa7952db2fa76c2e22986b628bc39844 authorJoe Hillenbrand <joehillen@gmail.com> dateSat 7 Jan 2017, 13:52 (10 years ago) parent779ef28
1 file changed+23
Network/HTTP/Req.hs+23
Network/HTTP/Req.hs+23
@@ -849,6 +849,29 @@ instance QueryParam FormUrlEncodedParam where
849849-- 'ReqBodyMultipart', as its constructor is not exported on purpose.
850850--
851851-- @since 0.2.0
852+--
853+-- ==== __Example__
854+--
855+-- > import Control.Exception (throwIO)
856+-- > import qualified Network.HTTP.Client.MultipartFormData as LM
857+-- > import Network.HTTP.Req
858+-- >
859+-- > instance MonadHttp IO where
860+-- > handleHttpException = throwIO
861+-- >
862+-- > main :: IO ()
863+-- > main = do
864+-- > body <-
865+-- > reqBodyMultipart
866+-- > [ LM.partBS "title" "My Image"
867+-- > , LM.partFileSource "file1" "/tmp/image.jpg"
868+-- > ]
869+-- > response <-
870+-- > req POST (http "example.com" /: "post")
871+-- > body
872+-- > bsResponse
873+-- > mempty
874+-- > print $ responseBody response
852875
853876data ReqBodyMultipart = ReqBodyMultipart ByteString LI.RequestBody
854877