open-pod/lib/podcast_feed_web/controllers/feed_controller.ex
2020-06-07 19:37:41 +00:00

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