Respond with a 404 Not implemented JSON error message
when requested API is not implemented
This commit is contained in:
parent
a13d449b24
commit
3ab9255eda
|
@ -74,6 +74,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
- Hide deactivated users and their statuses
|
||||
- Posts which are marked sensitive or tagged nsfw no longer have link previews.
|
||||
- HTTP connection timeout is now set to 10 seconds.
|
||||
- Respond with a 404 Not implemented JSON error message when requested API is not implemented
|
||||
|
||||
### Fixed
|
||||
- Added an FTS index on objects. Running `vacuum analyze` and setting a larger `work_mem` is recommended.
|
||||
|
|
|
@ -710,6 +710,7 @@ defmodule Pleroma.Web.Router do
|
|||
scope "/", Fallback do
|
||||
get("/registration/:token", RedirectController, :registration_page)
|
||||
get("/:maybe_nickname_or_id", RedirectController, :redirector_with_meta)
|
||||
get("/api*path", RedirectController, :api_not_implemented)
|
||||
get("/*path", RedirectController, :redirector)
|
||||
|
||||
options("/*path", RedirectController, :empty)
|
||||
|
@ -721,6 +722,12 @@ defmodule Fallback.RedirectController do
|
|||
alias Pleroma.User
|
||||
alias Pleroma.Web.Metadata
|
||||
|
||||
def api_not_implemented(conn, _params) do
|
||||
conn
|
||||
|> put_status(404)
|
||||
|> json(%{error: "Not implemented"})
|
||||
end
|
||||
|
||||
def redirector(conn, _params, code \\ 200) do
|
||||
conn
|
||||
|> put_resp_content_type("text/html")
|
||||
|
|
|
@ -24,6 +24,12 @@ test "GET /:maybe_nickname_or_id", %{conn: conn} do
|
|||
|> html_response(200) =~ "<!--server-generated-meta-->"
|
||||
end
|
||||
|
||||
test "GET /api*path", %{conn: conn} do
|
||||
assert conn
|
||||
|> get("/api/foo")
|
||||
|> json_response(404) == %{"error" => "Not implemented"}
|
||||
end
|
||||
|
||||
test "GET /*path", %{conn: conn} do
|
||||
assert conn
|
||||
|> get("/foo")
|
||||
|
|
Loading…
Reference in a new issue