Fix nodeinfo path

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2018-09-03 17:53:31 +02:00
parent 970a40c22e
commit c2875a6189
3 changed files with 15 additions and 8 deletions

View File

@ -11,7 +11,7 @@ defmodule EventosWeb.NodeinfoController do
links: [ links: [
%{ %{
rel: "http://nodeinfo.diaspora.software/ns/schema/2.0", rel: "http://nodeinfo.diaspora.software/ns/schema/2.0",
href: EventosWeb.Endpoint.url() <> "/nodeinfo/2.0.json" href: EventosWeb.Router.Helpers.nodeinfo_url(EventosWeb.Endpoint, :nodeinfo, "2.0")
} }
] ]
} }
@ -20,7 +20,7 @@ defmodule EventosWeb.NodeinfoController do
end end
# Schema definition: https://github.com/jhass/nodeinfo/blob/master/schemas/2.0/schema.json # Schema definition: https://github.com/jhass/nodeinfo/blob/master/schemas/2.0/schema.json
def nodeinfo(conn, %{"version" => "2.0.json"}) do def nodeinfo(conn, %{"version" => "2.0"}) do
import Logger import Logger
Logger.debug(inspect(@instance)) Logger.debug(inspect(@instance))
# stats = Stats.get_stats() # stats = Stats.get_stats()

View File

@ -30,6 +30,10 @@ defmodule EventosWeb.Router do
plug(:put_secure_browser_headers) plug(:put_secure_browser_headers)
end end
pipeline :nodeinfo do
plug(:accepts, ["html", "application/json"])
end
scope "/api", EventosWeb do scope "/api", EventosWeb do
pipe_through(:api) pipe_through(:api)
@ -67,6 +71,12 @@ defmodule EventosWeb.Router do
resources("/addresses", AddressController, only: [:index, :show]) resources("/addresses", AddressController, only: [:index, :show])
get("/search/:name", SearchController, :search) get("/search/:name", SearchController, :search)
scope "/nodeinfo" do
pipe_through(:nodeinfo)
get("/:version", NodeinfoController, :nodeinfo)
end
end end
end end
@ -110,10 +120,6 @@ defmodule EventosWeb.Router do
get("/nodeinfo", NodeinfoController, :schemas) get("/nodeinfo", NodeinfoController, :schemas)
end end
scope "/nodeinfo", EventosWeb do
get("/:version", NodeinfoController, :nodeinfo)
end
scope "/", EventosWeb do scope "/", EventosWeb do
pipe_through(:activity_pub) pipe_through(:activity_pub)

View File

@ -9,7 +9,8 @@ defmodule EventosWeb.NodeinfoControllerTest do
assert json_response(conn, 200) == %{ assert json_response(conn, 200) == %{
"links" => [ "links" => [
%{ %{
"href" => EventosWeb.Endpoint.url() <> "/nodeinfo/2.0.json", "href" =>
EventosWeb.Router.Helpers.nodeinfo_url(EventosWeb.Endpoint, :nodeinfo, "2.0"),
"rel" => "http://nodeinfo.diaspora.software/ns/schema/2.0" "rel" => "http://nodeinfo.diaspora.software/ns/schema/2.0"
} }
] ]
@ -17,7 +18,7 @@ defmodule EventosWeb.NodeinfoControllerTest do
end end
test "Get node info", %{conn: conn} do test "Get node info", %{conn: conn} do
conn = get(conn, nodeinfo_path(conn, :nodeinfo, "2.0.json")) conn = get(conn, nodeinfo_path(conn, :nodeinfo, "2.0"))
resp = json_response(conn, 200) resp = json_response(conn, 200)