2020-05-22 22:04:15 +02:00
|
|
|
defmodule PodcastFeedWeb.FeedController do
|
|
|
|
use PodcastFeedWeb, :controller
|
2020-06-07 21:37:41 +02:00
|
|
|
alias PodcastFeed.Boundary.ArchiveServer
|
|
|
|
|
|
|
|
def by_identifier(conn, %{"identifier" => identifier, "reload" => _}) do
|
|
|
|
do_by_identifier(conn, fn -> ArchiveServer.reload(identifier) end)
|
|
|
|
end
|
2020-05-22 22:04:15 +02:00
|
|
|
|
2020-05-23 23:56:20 +02:00
|
|
|
def by_identifier(conn, %{"identifier" => identifier}) do
|
2020-06-07 21:37:41 +02:00
|
|
|
do_by_identifier(conn, fn -> ArchiveServer.get_feed(identifier) end)
|
|
|
|
end
|
|
|
|
|
|
|
|
defp do_by_identifier(conn, fetcher) do
|
|
|
|
%{podcast: podcast, items: items} = fetcher.()
|
2020-05-23 23:56:20 +02:00
|
|
|
conn
|
|
|
|
|> put_resp_content_type("text/xml")
|
|
|
|
|> render("feed.xml", podcast: podcast, items: items)
|
|
|
|
end
|
2020-05-22 22:04:15 +02:00
|
|
|
end
|