mirror of
https://github.com/plausible/analytics.git
synced 2024-12-27 03:21:37 +03:00
6035618213
* Add `GET /capabilities` to Plugins API It aims to: - help the client verify the data-domain the token is associated with - list all the features available for the site's owner (and therefore determine availability of the subset of those for the current Plugins API caller) The endpoint does not require authentication, in the sense that it'll always respond with 200 OK. However when the token is provided, a verification lookup is made. * Remove IO.inspect() call * Credo * Aesthetics * s/send_resp/send_error/ * Call preload just once
25 lines
679 B
Elixir
25 lines
679 B
Elixir
defmodule PlausibleWeb.Plugins.API.Controllers.Capabilities do
|
|
@moduledoc """
|
|
Controller for Plugins API Capabilities - doesn't enforce authentication,
|
|
serves as a comprehensive health check
|
|
"""
|
|
use PlausibleWeb, :plugins_api_controller
|
|
|
|
operation(:index,
|
|
summary: "Retrieve Capabilities",
|
|
parameters: [],
|
|
responses: %{
|
|
ok: {"Capabilities response", "application/json", Schemas.Capabilities}
|
|
}
|
|
)
|
|
|
|
@spec index(Plug.Conn.t(), %{}) :: Plug.Conn.t()
|
|
def index(conn, _params) do
|
|
{:ok, capabilities} = API.Capabilities.get(conn)
|
|
|
|
conn
|
|
|> put_view(Views.Capabilities)
|
|
|> render("index.json", capabilities: capabilities)
|
|
end
|
|
end
|