mirror of
https://github.com/plausible/analytics.git
synced 2024-12-29 04:22:34 +03:00
bf2b6880c5
* Extract Sites.locked? predicate
* Lock Stats API when dashboard is locked
* Tidy tests
* Don't pollute application env from tests
* Add changelog entry
* Revert "Add changelog entry"
This reverts commit 76346074f9
.
39 lines
726 B
Elixir
39 lines
726 B
Elixir
defmodule PlausibleWeb.Api.Helpers do
|
|
import Plug.Conn
|
|
|
|
def unauthorized(conn, msg) do
|
|
conn
|
|
|> put_status(401)
|
|
|> Phoenix.Controller.json(%{error: msg})
|
|
|> halt()
|
|
end
|
|
|
|
def bad_request(conn, msg) do
|
|
conn
|
|
|> put_status(400)
|
|
|> Phoenix.Controller.json(%{error: msg})
|
|
|> halt()
|
|
end
|
|
|
|
def not_found(conn, msg) do
|
|
conn
|
|
|> put_status(404)
|
|
|> Phoenix.Controller.json(%{error: msg})
|
|
|> halt()
|
|
end
|
|
|
|
def too_many_requests(conn, msg) do
|
|
conn
|
|
|> put_status(429)
|
|
|> Phoenix.Controller.json(%{error: msg})
|
|
|> halt()
|
|
end
|
|
|
|
def payment_required(conn, msg) do
|
|
conn
|
|
|> put_status(402)
|
|
|> Phoenix.Controller.json(%{error: msg})
|
|
|> halt()
|
|
end
|
|
end
|