Browse Source

feat: added route to generate podcast throug identifier in the url

danilo silva 4 years ago
parent
commit
04ac723c12

+ 7 - 0
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

+ 6 - 0
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