@@ -1,7 +1,7 @@
11module Data.JsonSchema.Reference where
22
3+import Control.Arrow
34import Control.Exception
4−import Control.Lens
55import Control.Monad
66import Data.Aeson
77import Data.ByteString.Lazy (ByteString)
@@ -10,7 +10,7 @@ import qualified Data.HashMap.Strict as H
1010import Data.Monoid
1111import Data.Text (Text)
1212import qualified Data.Text as T
13−import Network.Wreq
13+import Network.HTTP.Conduit
1414import Prelude hiding (foldr)
1515
1616combineIdAndRef :: Text -> Text -> Text
@@ -47,18 +47,13 @@ fetchRef :: Text -> IO (Either Text (HashMap Text Value))
4747fetchRef t = do
4848 eResp <- safeGet t
4949 case eResp of
50− Left err -> return (Left err)
51− Right b ->
52− case eitherDecode b of
53− Right (Object z) -> return (Right z)
54− Right v -> return . Left $
55− "fetchRef returned the following instead of an object" <> T.pack (show v)
56− Left e -> return . Left . T.pack $ e
50+ Left e -> return $ Left e
51+ Right b -> return . left T.pack $ eitherDecode b
5752
5853safeGet :: Text -> IO (Either Text ByteString)
5954safeGet url =
6055 catch
61− (return . Right . (^. responseBody) =<< get (T.unpack url))
56+ (return . Right =<< (simpleHttp . T.unpack) url)
6257 handler
6358 where
6459 handler :: SomeException -> IO (Either Text ByteString)