From 04ac723c121378f93fb864b0238936db05dea2cb Mon Sep 17 00:00:00 2001 From: danilo silva Date: Sat, 23 May 2020 21:56:20 +0000 Subject: [PATCH] feat: added route to generate podcast throug identifier in the url --- lib/podcast_feed_web/controllers/feed_controller.ex | 7 +++++++ lib/podcast_feed_web/router.ex | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/lib/podcast_feed_web/controllers/feed_controller.ex b/lib/podcast_feed_web/controllers/feed_controller.ex index 6927dd4..7457eb0 100644 --- a/lib/podcast_feed_web/controllers/feed_controller.ex +++ b/lib/podcast_feed_web/controllers/feed_controller.ex @@ -7,4 +7,11 @@ defmodule PodcastFeedWeb.FeedController do |> put_resp_content_type("text/xml") |> render("feed.xml", podcast: podcast, items: items) end + + def by_identifier(conn, %{"identifier" => identifier}) do + %{podcast: podcast, items: items} = PodcastFeed.archive(identifier) + conn + |> put_resp_content_type("text/xml") + |> render("feed.xml", podcast: podcast, items: items) + end end diff --git a/lib/podcast_feed_web/router.ex b/lib/podcast_feed_web/router.ex index 1144ff8..83d0d4a 100644 --- a/lib/podcast_feed_web/router.ex +++ b/lib/podcast_feed_web/router.ex @@ -19,6 +19,12 @@ defmodule PodcastFeedWeb.Router do get "/ape-milano", FeedController, :apeMilano end + scope "/podcast", PodcastFeedWeb do + pipe_through :browser + + get "/:identifier", FeedController, :by_identifier + end + # Other scopes may use custom stacks. # scope "/api", PodcastFeedWeb do # pipe_through :api