Creating services
You will learn
- How
hyrule service createscaffolds a service - What it generates, and why it's a starting point, not a finished API
- How what it generates relates to everything in Learn
Scaffold a service
From the root of a project hyrule new created (it looks for a
services/ directory, so this fails outside one):
hyrule service create articles
This writes services/articles/:
main.go—app.Main(spec()), the same bootstrap Your First Resource builds by hand.resource.go— asetupfunction registering onerest.Resourcenamedarticles, with a minimal schema (one requirednamefield) andbehaviors/audit's hooks already wired in.resource_test.go— onetestkit-based test exercising a create and a get, the same pattern Testing walks through.
It's a starting point, not a finished resource
What's generated is deliberately small: one field, two methods
(GET/POST on the collection, GET/PATCH on an item), one
behavior. From here, everything in Learn applies
exactly as written — there's no Platform-specific resource format to
learn on top of it:
- Add fields and validation to
Schema— see Your First Resource and Reference →resources.yamlif you'd rather declare it as data. - Add relations to another service's resource, or a hook — see Relations and Hooks.
- Wire the transactional outbox — see The Transactional Outbox.
hyrule service create only saves you the boilerplate of the first
three files; what you build on top is the same framework, used the
same way, whether or not the CLI wrote the first line.
Recap
hyrule service create <name>writes a minimal, workingapp.Main+rest.Resource+ test — not a finished API.- Everything the Learn guide teaches about resources, hooks, relations and the outbox applies unchanged to a generated service.