2018-10-11 15:37:39 +00:00
|
|
|
defmodule MobilizonWeb.Router do
|
2018-01-14 16:56:50 +00:00
|
|
|
@moduledoc """
|
2018-10-11 15:37:39 +00:00
|
|
|
Router for mobilizon app
|
2018-01-14 16:56:50 +00:00
|
|
|
"""
|
2018-10-11 15:37:39 +00:00
|
|
|
use MobilizonWeb, :router
|
2017-12-08 08:58:14 +00:00
|
|
|
|
2018-11-06 09:30:27 +00:00
|
|
|
pipeline :graphql do
|
2018-07-27 08:45:35 +00:00
|
|
|
plug(:accepts, ["json"])
|
2018-11-06 09:30:27 +00:00
|
|
|
plug(MobilizonWeb.AuthPipeline)
|
2017-12-08 08:58:14 +00:00
|
|
|
end
|
|
|
|
|
2018-05-17 09:32:23 +00:00
|
|
|
pipeline :well_known do
|
2018-11-07 15:45:11 +00:00
|
|
|
plug(:accepts, ["json", "jrd-json"])
|
2018-05-17 09:32:23 +00:00
|
|
|
end
|
|
|
|
|
2018-11-12 17:17:53 +00:00
|
|
|
pipeline :activity_pub_signature do
|
2018-11-12 08:05:31 +00:00
|
|
|
plug(:accepts, ["activity-json", "html"])
|
2018-10-11 15:37:39 +00:00
|
|
|
plug(MobilizonWeb.HTTPSignaturePlug)
|
2018-05-17 09:32:23 +00:00
|
|
|
end
|
|
|
|
|
2018-11-12 17:17:53 +00:00
|
|
|
pipeline :activity_pub do
|
|
|
|
plug(:accepts, ["activity-json", "html"])
|
|
|
|
end
|
|
|
|
|
2018-01-09 16:52:26 +00:00
|
|
|
pipeline :browser do
|
2018-07-27 08:45:35 +00:00
|
|
|
plug(:accepts, ["html"])
|
|
|
|
plug(:fetch_session)
|
|
|
|
plug(:fetch_flash)
|
|
|
|
plug(:protect_from_forgery)
|
|
|
|
plug(:put_secure_browser_headers)
|
2018-01-09 16:52:26 +00:00
|
|
|
end
|
|
|
|
|
2018-09-03 15:53:31 +00:00
|
|
|
pipeline :nodeinfo do
|
|
|
|
plug(:accepts, ["html", "application/json"])
|
|
|
|
end
|
|
|
|
|
2018-11-06 09:30:27 +00:00
|
|
|
scope "/api" do
|
|
|
|
pipe_through(:graphql)
|
2018-07-27 08:45:35 +00:00
|
|
|
|
2018-11-06 09:30:27 +00:00
|
|
|
forward("/", Absinthe.Plug, schema: MobilizonWeb.Schema)
|
2017-12-08 08:58:14 +00:00
|
|
|
end
|
|
|
|
|
2018-11-06 09:30:27 +00:00
|
|
|
forward("/graphiql", Absinthe.Plug.GraphiQL, schema: MobilizonWeb.Schema)
|
2018-05-17 09:32:23 +00:00
|
|
|
|
2018-10-11 15:37:39 +00:00
|
|
|
scope "/.well-known", MobilizonWeb do
|
2018-07-27 08:45:35 +00:00
|
|
|
pipe_through(:well_known)
|
2018-05-17 09:32:23 +00:00
|
|
|
|
2018-07-27 08:45:35 +00:00
|
|
|
get("/host-meta", WebFingerController, :host_meta)
|
|
|
|
get("/webfinger", WebFingerController, :webfinger)
|
2018-11-06 09:30:27 +00:00
|
|
|
get("/nodeinfo", NodeInfoController, :schemas)
|
|
|
|
get("/nodeinfo/:version", NodeInfoController, :nodeinfo)
|
2018-05-17 09:32:23 +00:00
|
|
|
end
|
|
|
|
|
2018-10-11 15:37:39 +00:00
|
|
|
scope "/", MobilizonWeb do
|
2018-07-27 08:45:35 +00:00
|
|
|
pipe_through(:activity_pub)
|
|
|
|
|
|
|
|
get("/@:name", ActivityPubController, :actor)
|
|
|
|
get("/@:name/outbox", ActivityPubController, :outbox)
|
|
|
|
get("/@:name/following", ActivityPubController, :following)
|
|
|
|
get("/@:name/followers", ActivityPubController, :followers)
|
|
|
|
get("/events/:uuid", ActivityPubController, :event)
|
2018-11-12 08:05:31 +00:00
|
|
|
get("/comments/:uuid", ActivityPubController, :comment)
|
2018-11-12 17:17:53 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
scope "/", MobilizonWeb do
|
|
|
|
pipe_through(:activity_pub_signature)
|
2018-07-27 08:45:35 +00:00
|
|
|
post("/@:name/inbox", ActivityPubController, :inbox)
|
|
|
|
post("/inbox", ActivityPubController, :inbox)
|
2017-12-08 08:58:14 +00:00
|
|
|
end
|
2018-01-09 16:52:26 +00:00
|
|
|
|
2018-07-27 08:45:35 +00:00
|
|
|
if Mix.env() == :dev do
|
2018-07-04 12:29:17 +00:00
|
|
|
# If using Phoenix
|
2018-07-27 08:45:35 +00:00
|
|
|
forward("/sent_emails", Bamboo.SentEmailViewerPlug)
|
2018-07-04 12:29:17 +00:00
|
|
|
end
|
|
|
|
|
2018-10-11 15:37:39 +00:00
|
|
|
scope "/", MobilizonWeb do
|
2018-07-27 08:45:35 +00:00
|
|
|
pipe_through(:browser)
|
2018-01-09 16:52:26 +00:00
|
|
|
|
2018-11-06 09:30:27 +00:00
|
|
|
forward("/uploads", UploadPlug)
|
2018-07-27 08:45:35 +00:00
|
|
|
get("/*path", PageController, :index)
|
2018-01-09 16:52:26 +00:00
|
|
|
end
|
2017-12-08 08:58:14 +00:00
|
|
|
end
|