Last active
June 1, 2020 20:30
-
-
Save owainlewis/4132852 to your computer and use it in GitHub Desktop.
Haskell HTTP GET request example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Example () where | |
import Network.HTTP | |
-- Non HTTPS | |
-- 1. Perform a basic HTTP get request and return the body | |
get :: String -> IO String | |
get url = simpleHTTP (getRequest url) >>= getResponseBody | |
-- 2. Get the response code | |
getCode :: String -> IO ResponseCode | |
getCode url = simpleHTTP req >>= getResponseCode | |
where req = getRequest url |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment