elixir_rss/lib/fetch_rss.ex

15 lines
291 B
Elixir
Raw Normal View History

2024-10-11 03:04:34 +00:00
defmodule ElixirRss.Fetch do
def fetch(url) do
url
|> HTTPoison.get()
|> handle_response()
end
defp handle_response({:ok, %{status_code: 200, body: body}}) do
{:ok, body}
end
defp handle_response({_, %{status_code: _, body: body}}) do
{:error, body}
end
end