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

Resource Links

Implement this protocol to generate JSON:API links for individual resources. Links returned will be included for each resource links in JSON:API responses.

This example implementation generates a link for each MyApp.Post resource.

defimpl JSONAPIPlug.Resource.Links, for: MyApp.Post do
  def links(%@for{} = post, _conn), do: %{some-link: "http://myapp.com/post/#{post.id}/other-stuff"}
end

Summary

Types

t()

All the types that implement this protocol.

Types

@type t() :: term()

All the types that implement this protocol.

Functions

Resource links

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