module Follow.Fetchers.Feed
( fetch
, FeedError(..)
) where
import Control.Monad.Catch (MonadThrow)
import qualified Data.ByteString as BS (ByteString)
import Follow.Fetchers.Feed.Internal
import Follow.Types (Fetched)
import HTTP.Follow (getResponseBody, parseUrl)
import qualified Network.HTTP.Req as R (MonadHttp)
fetch :: (R.MonadHttp m, MonadThrow m) => BS.ByteString -> Fetched m
fetch url = do
url' <- parseUrl url
response <- getResponseBody url'
feed <- parseFeed response
return $ feedToEntries feed