19 lines
685 B
Elixir
19 lines
685 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, identifier, fn -> ArchiveServer.reload(identifier) end)
|
|
end
|
|
|
|
def by_identifier(conn, %{"identifier" => identifier}) do
|
|
do_by_identifier(conn, identifier, fn -> ArchiveServer.get_feed(identifier) end)
|
|
end
|
|
|
|
defp do_by_identifier(conn, identifier, fetcher) do
|
|
%{podcast: podcast, items: items} = fetcher.()
|
|
conn
|
|
|> put_resp_content_type("text/xml")
|
|
|> render("feed.xml", identifier: identifier, podcast: podcast, items: items)
|
|
end
|
|
end
|