Snodo.Resource with plain return values from read/2.
It accepts every Snodo.Resource option and produces the same definition and
matcher. The difference is what read/2 may return:
{:ok, text}with a binary is one text content at the requested URI, carrying the declared:mime_type.{:ok, value}with any other JSON value is one JSON content, with"application/json"unless another:mime_typeis declared.{:ok, %Snodo.Result{}}and{:error, reason}pass through unchanged. UseSnodo.Result.resource_read/2for blobs, several contents, cache hints, or content metadata, andSnodo.Result.input_required/1for MRTR.
JSON values must already use string keys; Snodo.JSONValue.encodable!/1
converts an atom-keyed domain value.
defmodule ToolboxGroups do
use Snodo.Resource.Simple,
uri: "toolbox://groups",
name: "toolbox_groups",
mime_type: "application/json"
@impl true
def read(_params, _context), do: {:ok, %{"groups" => ["web", "data"]}}
endThe conversion wraps the module's own read/2, so Snodo.Router receives an
Snodo.Result exactly as it does from a plain Snodo.Resource.