View Source JSONAPIPlug.Resource.Meta protocol (jsonapi_plug v2.0.0)

Resource Links

Implement this protocol to generate JSON:API metadata for indivudual resources. Metadata returned will be included for each resource meta in JSON:API responses.

This example implementation generates metadata for each MyApp.Post resource.

  defimpl JSONAPIPlug.Resource.Meta, for: MyApp.Post do
    def meta(%@for{} = post, _conn), do: %{slug: to_slug(post.title)}

    defp to_slug(string), do: string  |> String.downcase |> String.replace(" ", "-")
  end

Summary

Types

t()

All the types that implement this protocol.

Types

@type t() :: term()

All the types that implement this protocol.

Functions

Resource meta

Returns the resource meta to be returned for resources by the resource.