feed_controller.ex 625 B

12345678910111213141516171819
  1. defmodule PodcastFeedWeb.FeedController do
  2. use PodcastFeedWeb, :controller
  3. alias PodcastFeed.Boundary.ArchiveServer
  4. def by_identifier(conn, %{"identifier" => identifier, "reload" => _}) do
  5. do_by_identifier(conn, fn -> ArchiveServer.reload(identifier) end)
  6. end
  7. def by_identifier(conn, %{"identifier" => identifier}) do
  8. do_by_identifier(conn, fn -> ArchiveServer.get_feed(identifier) end)
  9. end
  10. defp do_by_identifier(conn, fetcher) do
  11. %{podcast: podcast, items: items} = fetcher.()
  12. conn
  13. |> put_resp_content_type("text/xml")
  14. |> render("feed.xml", podcast: podcast, items: items)
  15. end
  16. end