milad zahedi
milad zahedi

Reputation: 807

How to send an http request using snap-framework?

I want to send an http request to an external API using the Snap framework. Does Snap support it? If not, how to go about it?

Upvotes: 4

Views: 374

Answers (1)

Babra Cunningham
Babra Cunningham

Reputation: 2967

Have you looked at using Network.Wreq?

import qualified Data.ByteString.Lazy as LAZ
import qualified Data.ByteString.Lazy.Char8 as CHA

makeRequest :: IO (Network.Wreq.Response LAZ.ByteString)
makeRequest = do
   res <- get "https://www.example.com"
   let resBody = res ^. responseBody :: CHA.ByteString
   return (resBody)

Uses simple lens syntax and supports HTTP and HTTPS.

Upvotes: 2

Related Questions