From 56b93d42e5cf8cf46e3da1bebc117468a00985d1 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 7 Apr 2024 12:08:17 -0400 Subject: [PATCH] Version endpoints --- .../controllers/registrations_controller.ex | 4 ++-- lib/tusker_push_web/router.ex | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/tusker_push_web/controllers/registrations_controller.ex b/lib/tusker_push_web/controllers/registrations_controller.ex index 40f92c3..ffdb789 100644 --- a/lib/tusker_push_web/controllers/registrations_controller.ex +++ b/lib/tusker_push_web/controllers/registrations_controller.ex @@ -21,7 +21,7 @@ defmodule TuskerPushWeb.RegistrationsController do conn |> json(%{ id: id, - endpoint: url(~p"/mastodon/push/#{id}") + endpoint: url(~p"/mastodon/v1/push/#{id}") }) else {:error, %Changeset{valid?: false} = changeset} -> @@ -64,7 +64,7 @@ defmodule TuskerPushWeb.RegistrationsController do {:registration, TuskerPush.get_registration(id)}, {:ok, _} <- TuskerPush.update_registration(registration, params) do conn - |> json(%{id: id, endpoint: url(~p"/mastodon/push/#{id}")}) + |> json(%{id: id, endpoint: url(~p"/mastodon/v1/push/#{id}")}) else {:registration, nil} -> conn diff --git a/lib/tusker_push_web/router.ex b/lib/tusker_push_web/router.ex index 4f4c68b..33c6947 100644 --- a/lib/tusker_push_web/router.ex +++ b/lib/tusker_push_web/router.ex @@ -8,12 +8,16 @@ defmodule TuskerPushWeb.Router do scope "/app", TuskerPushWeb do pipe_through :api - resources "/registrations", RegistrationsController, only: [:create, :update, :delete] + scope "/v1" do + resources "/registrations", RegistrationsController, only: [:create, :update, :delete] + end end scope "/mastodon", TuskerPushWeb do pipe_through :api - post "/push/:id", PushController, :push + scope "/v1" do + post "/push/:id", PushController, :push + end end end