pagantis_elixir_tools v0.17.5 ElixirTools.JsonApi.Controller

Works together with the JsonApi. The JSON API expects a validated request and converts the controller into a Json Api Controller by passing only the validated parameters using JaSerializer.

Allows two action_name calls:

  1. action_name/2. Calls the action name with the params: conn, json_api_params
  2. action_name/3. To keep access to original parameter object it will call

                 `conn, phoenix_params, json_api_params`

Example:

defmodule Controller do
  use MyPhoenixWeb, :controller
  use ElixirTools.JsonApi.Controller

  def my_method(conn, json_params), do: conn
  def my_method(conn, phoenix_params, json_params), do: conn
end

Link to this section Summary

Link to this section Types

Link to this type

idempotency_key()

idempotency_key() :: Ecto.UUID.t() | nil
Link to this type

params()

params() :: map()

Link to this section Functions

Link to this function

bad_input(conn, error \\ "Bad Request")

bad_input(Plug.Conn.t(), error()) :: Plug.Conn.t()
Link to this function

http_timeout(conn, error \\ "Request Timeout")

http_timeout(Plug.Conn.t(), error()) :: Plug.Conn.t()
Link to this function

not_found(conn, error \\ "Not Found")

not_found(Plug.Conn.t(), error()) :: Plug.Conn.t()
Link to this function

server_error(conn, error)

server_error(Plug.Conn.t(), error()) :: Plug.Conn.t()
Link to this function

unprocessable_entity(conn, error \\ "Unprocessable Entity")

unprocessable_entity(Plug.Conn.t(), error()) :: Plug.Conn.t()
Link to this function

validate_params(params, schema)

validate_params(map(), module()) ::
  {:ok, struct()} | {:error, {:bad_request, map()}}