19 lines
625 B
Elixir
19 lines
625 B
Elixir
defmodule PodcastFeedWeb.FeedController do
|
|
use PodcastFeedWeb, :controller
|
|
alias PodcastFeed.Boundary.ArchiveServer
|
|
|
|
def by_identifier(conn, %{"identifier" => identifier, "reload" => _}) do
|
|
do_by_identifier(conn, fn -> ArchiveServer.reload(identifier) end)
|
|
end
|
|
|
|
def by_identifier(conn, %{"identifier" => identifier}) do
|
|
do_by_identifier(conn, fn -> ArchiveServer.get_feed(identifier) end)
|
|
end
|
|
|
|
defp do_by_identifier(conn, fetcher) do
|
|
%{podcast: podcast, items: items} = fetcher.()
|
|
conn
|
|
|> put_resp_content_type("text/xml")
|
|
|> render("feed.xml", podcast: podcast, items: items)
|
|
end
|
|
end
|