Permalink
Browse files

added stories controller and connected the router with controller act…

…ion + removed default page controller
  • Loading branch information...
jasdeepsingh committed Mar 2, 2016
1 parent 31d8669 commit ae99f8f77d4e5c80a7f11d1f86566a658027dd35
@@ -1,7 +0,0 @@
defmodule HackernewsApi.PageController do
use HackernewsApi.Web, :controller
def index(conn, _params) do
render conn, "index.html"
end
end
@@ -0,0 +1,8 @@
defmodule HackernewsApi.StoriesController do
use HackernewsApi.Web, :controller
def top_stories(conn, _params) do
json(conn, %{ hello: :world })
end
end
View
@@ -13,14 +13,10 @@ defmodule HackernewsApi.Router do
plug :accepts, ["json"]
end
scope "/", HackernewsApi do
pipe_through :browser # Use the default browser stack
# Other scopes may use custom stacks.
scope "/api", HackernewsApi do
pipe_through :api
get "/", PageController, :index
get "/top-stories", StoriesController, :top_stories
end
# Other scopes may use custom stacks.
# scope "/api", HackernewsApi do
# pipe_through :api
# end
end
@@ -7,7 +7,7 @@
<meta name="description" content="">
<meta name="author" content="">
<title>Hello HackernewsApi!</title>
<title>Hacker News API</title>
<link rel="stylesheet" href="<%= static_path(@conn, "/css/app.css") %>">
</head>

0 comments on commit ae99f8f

Please sign in to comment.