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
{-# LANGUAGE OverloadedStrings #-} | |
import Control.Monad.Exception.Synchronous | |
import Data.Conduit | |
import qualified Control.Exception as E | |
import Network.HTTP.Types.Status | |
import Network.HTTP.Conduit | |
import qualified Data.ByteString.Lazy as L | |
import qualified Network (withSocketsDo) | |
import Control.Exception as E | |
import Control.Monad.Trans | |
noRedirect :: Request a -> Request a | |
noRedirect request = request { redirectCount = 0 } | |
noCheckStatus :: Request a -> Request a | |
noCheckStatus request = request { checkStatus = \_ _ _ -> Nothing } | |
resolveURL url = parseUrl url | |
>>= withManager . httpLbs . noRedirect . noCheckStatus | |
>>= return | |
resolvePrefix prefix = do | |
response <- resolveURL $ "http://prefix.cc/" ++ prefix ++ ".go" | |
return $ lookup "Location" $ responseHeaders response | |
main = resolvePrefix "rdfs" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment