Update routes

This commit is contained in:
Mirai Kumiko 2025-06-27 16:50:24 +02:00
parent 2cfc459cd0
commit 88b8b379e7
Signed by: miraikumiko
GPG key ID: 3F178B1B5E0CB278
2 changed files with 24 additions and 16 deletions

View file

@ -17,7 +17,7 @@ defmodule NullaWeb.ActorController do
|> json(%{error: "Not Found"})
%Actor{} = actor ->
if accept in ["application/activity+json", "application/ld+json"] do
if accept in ["application/activity+json"] do
conn
|> put_resp_content_type("application/activity+json")
|> send_resp(200, Jason.encode!(ActivityPub.actor(actor)))

View file

@ -2,7 +2,7 @@ defmodule NullaWeb.Router do
use NullaWeb, :router
pipeline :browser do
plug :accepts, ["html", "json", "activity+json", "ld+json"]
plug :accepts, ["html", "json", "activity+json"]
plug :fetch_session
plug :fetch_live_flash
plug :put_root_layout, html: {NullaWeb.Layouts, :root}
@ -14,6 +14,10 @@ defmodule NullaWeb.Router do
plug :accepts, ["json"]
end
pipeline :activitypub do
plug :accepts, ["activity+json"]
end
scope "/", NullaWeb do
pipe_through :browser
@ -23,7 +27,6 @@ defmodule NullaWeb.Router do
get "/.well-known/webfinger", WebfingerController, :index
get "/.well-known/nodeinfo", NodeinfoController, :index
get "/nodeinfo/2.0", NodeinfoController, :show
post "/inbox", InboxController, :inbox
scope "/auth" do
post "/", AuthController, :sign_up
@ -33,15 +36,6 @@ defmodule NullaWeb.Router do
get "/sign_in", PageController, :sign_in
end
scope "/users/:username" do
get "/", ActorController, :show
get "/following", FollowController, :following
get "/followers", FollowController, :followers
post "/inbox", InboxController, :inbox
get "/outbox", OutboxController, :outbox
get "/notes/:id", NoteController, :show
end
scope "/@:username" do
get "/", ActorController, :show
get "/following", FollowController, :following
@ -52,10 +46,24 @@ defmodule NullaWeb.Router do
end
end
# Other scopes may use custom stacks.
# scope "/api", NullaWeb do
# pipe_through :api
# end
scope "/api", NullaWeb do
pipe_through :api
end
scope "/", NullaWeb do
pipe_through :activitypub
post "/inbox", InboxController, :inbox
scope "/users/:username" do
get "/", ActorController, :show
get "/following", FollowController, :following
get "/followers", FollowController, :followers
post "/inbox", InboxController, :inbox
get "/outbox", OutboxController, :outbox
get "/notes/:id", NoteController, :show
end
end
# Enable LiveDashboard and Swoosh mailbox preview in development
if Application.compile_env(:nulla, :dev_routes) do