diff --git a/lib/plenario_web.ex b/lib/plenario_web.ex index 3bed920..8022d72 100644 --- a/lib/plenario_web.ex +++ b/lib/plenario_web.ex @@ -46,7 +46,7 @@ defmodule PlenarioWeb do def api_controller do quote do - use Phoenix.Controller, namespece: PlenarioWeb.Api + use Phoenix.Controller, namespace: PlenarioWeb.Api import Plug.Conn import Canary.Plugs end @@ -110,6 +110,7 @@ defmodule PlenarioWeb do def api_view do quote do use Phoenix.View, + root: "lib/plenario_web/templates/api", namespace: PlenarioWeb.Api import Phoenix.Controller, only: [view_module: 1] import PlenarioWeb.Router.Helpers diff --git a/lib/plenario_web/controllers/api/aot_controller.ex b/lib/plenario_web/controllers/api/aot_controller.ex new file mode 100644 index 0000000..cb07f99 --- /dev/null +++ b/lib/plenario_web/controllers/api/aot_controller.ex @@ -0,0 +1,15 @@ +defmodule PlenarioWeb.Api.AotController do + use PlenarioWeb, :api_controller + + def get(conn, _params) do + render(conn, "get.json", %{}) + end + + def head(conn, _params) do + render(conn, "head.json", %{}) + end + + def describe(conn, _params) do + render(conn, "describe.json", %{}) + end +end diff --git a/lib/plenario_web/controllers/api/detail_controller.ex b/lib/plenario_web/controllers/api/detail_controller.ex new file mode 100644 index 0000000..a52ac0a --- /dev/null +++ b/lib/plenario_web/controllers/api/detail_controller.ex @@ -0,0 +1,15 @@ +defmodule PlenarioWeb.Api.DetailController do + use PlenarioWeb, :api_controller + + def get(conn, _params) do + render(conn, "get.json", %{}) + end + + def head(conn, _params) do + render(conn, "head.json", %{}) + end + + def describe(conn, _params) do + render(conn, "describe.json", %{}) + end +end diff --git a/lib/plenario_web/controllers/api/list_controller.ex b/lib/plenario_web/controllers/api/list_controller.ex new file mode 100644 index 0000000..1547682 --- /dev/null +++ b/lib/plenario_web/controllers/api/list_controller.ex @@ -0,0 +1,15 @@ +defmodule PlenarioWeb.Api.ListController do + use PlenarioWeb, :api_controller + + def get(conn, _params) do + render(conn, "get.json", %{}) + end + + def head(conn, _params) do + render(conn, "head.json", %{}) + end + + def describe(conn, _params) do + render(conn, "describe.json", %{}) + end +end diff --git a/lib/plenario_web/router.ex b/lib/plenario_web/router.ex index ecd5221..c3a34c9 100644 --- a/lib/plenario_web/router.ex +++ b/lib/plenario_web/router.ex @@ -99,8 +99,20 @@ defmodule PlenarioWeb.Router do ## # api paths - scope "/api", PlenarioWeb.Api do + scope "/api/v2", PlenarioWeb.Api do pipe_through [:api] + + get "/data-sets", ListController, :get + get "/data-sets/@head", ListController, :head + get "/data-sets/@describe", ListController, :describe + + get "/detail", DetailController, :get + get "/detail/@head", DetailController, :head + get "/detail/@describe", DetailController, :describe + + get "/aot", AotController, :get + get "/aot/@head", AotController, :head + get "/aot/@describe", AotController, :describe end end diff --git a/lib/plenario_web/views/api/aot_view.ex b/lib/plenario_web/views/api/aot_view.ex new file mode 100644 index 0000000..2b25012 --- /dev/null +++ b/lib/plenario_web/views/api/aot_view.ex @@ -0,0 +1,15 @@ +defmodule PlenarioWeb.Api.AotView do + use PlenarioWeb, :api_view + + def render("get.json", _params) do + %{} + end + + def render("head.json", _params) do + %{} + end + + def render("describe.json", _params) do + %{} + end +end diff --git a/lib/plenario_web/views/api/detail_view.ex b/lib/plenario_web/views/api/detail_view.ex new file mode 100644 index 0000000..3b23405 --- /dev/null +++ b/lib/plenario_web/views/api/detail_view.ex @@ -0,0 +1,15 @@ +defmodule PlenarioWeb.Api.DetailView do + use PlenarioWeb, :api_view + + def render("get.json", _params) do + %{} + end + + def render("head.json", _params) do + %{} + end + + def render("describe.json", _params) do + %{} + end +end diff --git a/lib/plenario_web/views/api/list_view.ex b/lib/plenario_web/views/api/list_view.ex new file mode 100644 index 0000000..dfbd438 --- /dev/null +++ b/lib/plenario_web/views/api/list_view.ex @@ -0,0 +1,15 @@ +defmodule PlenarioWeb.Api.ListView do + use PlenarioWeb, :api_view + + def render("get.json", _params) do + %{} + end + + def render("head.json", _params) do + %{} + end + + def render("describe.json", _params) do + %{} + end +end diff --git a/mix.exs b/mix.exs index a7efa53..c236e43 100644 --- a/mix.exs +++ b/mix.exs @@ -4,7 +4,7 @@ defmodule Plenario.Mixfile do def project do [ app: :plenario, - version: "0.3.0", + version: "0.4.0", elixir: "~> 1.6", elixirc_paths: elixirc_paths(Mix.env()), compilers: [:phoenix, :gettext] ++ Mix.compilers(), diff --git a/test/plenario_web/controllers/api/aot_controller_test.exs b/test/plenario_web/controllers/api/aot_controller_test.exs new file mode 100644 index 0000000..451ba18 --- /dev/null +++ b/test/plenario_web/controllers/api/aot_controller_test.exs @@ -0,0 +1,18 @@ +defmodule PlenarioWeb.Api.AotControllerTest do + use PlenarioWeb.Testing.ConnCase + + test "GET /api/v2/aot", %{conn: conn} do + conn = get(conn, "/api/v2/aot") + assert json_response(conn, 200) == %{} + end + + test "GET /api/v2/aot/@head", %{conn: conn} do + conn = get(conn, "/api/v2/aot/@head") + assert json_response(conn, 200) == %{} + end + + test "GET /api/v2/aot/@describe", %{conn: conn} do + conn = get(conn, "/api/v2/aot/@describe") + assert json_response(conn, 200) == %{} + end +end diff --git a/test/plenario_web/controllers/api/detail_controller_test.exs b/test/plenario_web/controllers/api/detail_controller_test.exs new file mode 100644 index 0000000..a7fe151 --- /dev/null +++ b/test/plenario_web/controllers/api/detail_controller_test.exs @@ -0,0 +1,18 @@ +defmodule PlenarioWeb.Api.DetailControllerTest do + use PlenarioWeb.Testing.ConnCase + + test "GET /api/v2/detail", %{conn: conn} do + conn = get(conn, "/api/v2/detail") + assert json_response(conn, 200) == %{} + end + + test "GET /api/v2/detail/@head", %{conn: conn} do + conn = get(conn, "/api/v2/detail/@head") + assert json_response(conn, 200) == %{} + end + + test "GET /api/v2/detail/@describe", %{conn: conn} do + conn = get(conn, "/api/v2/detail/@describe") + assert json_response(conn, 200) == %{} + end +end diff --git a/test/plenario_web/controllers/api/list_controller_test.exs b/test/plenario_web/controllers/api/list_controller_test.exs new file mode 100644 index 0000000..e16ff3f --- /dev/null +++ b/test/plenario_web/controllers/api/list_controller_test.exs @@ -0,0 +1,18 @@ +defmodule PlenarioWeb.Api.ListControllerTest do + use PlenarioWeb.Testing.ConnCase + + test "GET /api/v2/data-sets", %{conn: conn} do + conn = get(conn, "/api/v2/data-sets") + assert json_response(conn, 200) == %{} + end + + test "GET /api/v2/data-sets/@head", %{conn: conn} do + conn = get(conn, "/api/v2/data-sets") + assert json_response(conn, 200) == %{} + end + + test "GET /api/v2/data-sets/@describe", %{conn: conn} do + conn = get(conn, "/api/v2/data-sets") + assert json_response(conn, 200) == %{} + end +end