Add some basic code
This commit is contained in:
18
lib/elixir_rss.ex
Normal file
18
lib/elixir_rss.ex
Normal file
@@ -0,0 +1,18 @@
|
||||
defmodule ElixirRss do
|
||||
@moduledoc """
|
||||
Documentation for `ElixirRss`.
|
||||
"""
|
||||
|
||||
@doc """
|
||||
Hello world.
|
||||
|
||||
## Examples
|
||||
|
||||
iex> ElixirRss.hello()
|
||||
:world
|
||||
|
||||
"""
|
||||
def hello do
|
||||
:world
|
||||
end
|
||||
end
|
||||
14
lib/fetch_rss.ex
Normal file
14
lib/fetch_rss.ex
Normal file
@@ -0,0 +1,14 @@
|
||||
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
|
||||
Reference in New Issue
Block a user