mirror of
https://github.com/plausible/analytics.git
synced 2024-12-20 16:11:49 +03:00
32 lines
590 B
Elixir
32 lines
590 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
|
|
end
|