mirror of
https://github.com/plausible/analytics.git
synced 2024-12-29 20:42:01 +03:00
082ec91c63
* Update depenedencies: OpenAPISpex + cursor based pagination * Update formatter config * Add internal server error implementation * Test errors * Implement pagination interface * Implement Plugins API module macros * Implement Public API base URI (to be used with path helpers once called from within forwarded router's scope) * Implement OpenAPI specs + schemas * Implement Shared Links context module * Add pagination and error views * Add Shared Link view * Implement Shared Link controller * Expose SharedLink.t() spec * Implement separate router for the Plugins API * Update moduledocs * Always wrap resource objects with `data` * Update moduledoc * Use https://github.com/open-api-spex/open_api_spex/pull/425 due to https://github.com/open-api-spex/open_api_spex/issues/92 * Rely on BASE_URL for swagger-ui server definition * Fixup goals migration * Migrate broken goals before deleting dupes * Remove bypassing test rate limiting for which there's none anyway * Move the context module under `Plausible.` namespace * Bring back conn assignment to PluginsAPICase template * Update test/plausible_web/plugins/api/controllers/shared_links_test.exs Co-authored-by: Uku Taht <Uku.taht@gmail.com> * Update renamed aliases * Seed static token for development purposes * Delegate Plugins API 500s to a familiar shape * Simplify with statement --------- Co-authored-by: Uku Taht <Uku.taht@gmail.com>
24 lines
601 B
Elixir
24 lines
601 B
Elixir
defmodule PlausibleWeb.Plugins.API.Views.Error do
|
|
@moduledoc """
|
|
View for rendering Plugins REST API errors
|
|
"""
|
|
use PlausibleWeb, :plugins_api_view
|
|
|
|
def template_not_found(_template, assigns) do
|
|
render("500.json", assigns)
|
|
end
|
|
|
|
@spec render(String.t(), map) :: map | binary()
|
|
def render("400.json", _assigns) do
|
|
%{errors: [%{detail: "Bad request"}]}
|
|
end
|
|
|
|
def render("404.json", _assigns) do
|
|
%{errors: [%{detail: "Plugins API: resource not found"}]}
|
|
end
|
|
|
|
def render("500.json", _assigns) do
|
|
%{errors: [%{detail: "Plugins API: Internal server error"}]}
|
|
end
|
|
end
|