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.22 Kb · 48 lines

gno.land/r/moul/demo/render

Step 4 of the r/moul/demo walkthrough: Render, the read-only view a realm exposes to gnoweb.

1func Render(path string) string

Render receives whatever follows the : in the URL and routes on it. Three routes are wired here:

path output
"" an index linking to the other two
"hello" Hello World!
"greetings/<name>" Welcome, <Name>!
anything else 404

Render is a query, not a transaction: no gas, no signature, and it must be deterministic.

1gnokey query vm/qrender -data 'gno.land/r/moul/demo/render:greetings/manfred' \
2  -remote https://rpc.gno.land:443

Caveat, kept on purpose. The index route still emits links to /r/moul_basics_004:, the path this code was written against in an older workshop. They do not resolve at this realm's current path. It is a good illustration of the trap: a hardcoded self-link becomes wrong the moment the realm moves, so build links from the request path (see p/moul/realmpath) instead.

Previous: data. Next: wikicoin builds a ledger.


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

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