Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

README.md

2.51 Kb · 54 lines

gno.land/r/moul/outfmt

A realm that returns the same data in three shapes, selected by a query parameter. It exists to show that Render is a general response builder and not only a Markdown emitter.

path output
"" an index of the three formats
?fmt=stringer human-readable text (the default)
?fmt=json a JSON object
?fmt=jsonp the same JSON wrapped in callback(...)

Anything else panics.

1gnokey query vm/qrender -data 'gno.land/r/moul/outfmt:?fmt=json' \
2  -remote https://rpc.gno.land:443

The payload is a Result (a number, a text, a slice of numbers) drawn from a package-level math/rand source with a fixed seed (rand.NewPCG(0, 0)). A Render call is a query, so the draws it makes are never committed.

Known rough edges

Both are marked FIXME in the source and are kept as-is, because they are the interesting part:

  • The query string is split by hand on ? and = instead of going through net/url, so ?fmt=json&x=1 does not parse.
  • Nothing can set a content type. A realm returns a string; the JSON variant is JSON only by convention, and the jsonp callback name is hardcoded to callback rather than read from the query.

A realm cannot negotiate content properly today. That limitation is what this realm documents.


Part of moul/gno-contracts — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage.

On mainnet: deployment status transactions unique callers deployed revision

Dependency graph:

gno.land/r/moul/outfmt/v0 dependency graph

⚠️ Disclaimer: provided as-is, without warranty; not security-audited. Full disclaimer: DISCLAIMER.