Services Yaml
This is a multi-file example. Use the links below to inspect each source file in the example tree.
services.yaml end-to-end demo
A small two-route app that wires parameters, services entries with arg overrides, an interface binding, per-env overlays, and the encrypted-file secrets provider.
What it shows
config/services.yamlcarries the prod layout: realHttpFeedClientwith anapiKeyresolved from%secret(feed.api_key)%, a parameter chain that builds the endpoint from%feed.host%, and abindings:entry choosingHttpFeedClientforFeedClient.config/services_dev.yamlrebindsFeedClient -> StubFeedClientand overridesfeed.host. Selected whenGEBWEB_ENV=dev.main.gbonly attaches the secrets provider when the env is notdev, so the stub path needs no vault.
Run with the stub (no secrets)
cd examples/services_yaml
GEBWEB_ENV=dev geblang main.gb
curl http://127.0.0.1:8080/feed
# {"items":["stub:item-a","stub:item-b","stub:item-c"]}
Run against the live binding (with the encrypted vault)
cd examples/services_yaml
../../../gebweb secrets init
../../../gebweb secrets set feed.api_key sk_live_demo
GEBWEB_SECRETS_KEY=$(cat config/secrets.key) geblang main.gb
curl http://127.0.0.1:8080/feed
# {"items":["live:https://demo.example.com/v1/items?key=sk_live_demo"]}
Tests
cd examples/services_yaml
geblang test tests/
The test suite exercises the dev overlay path so the assertions don't depend on a populated vault.
Files
config/services.yaml- base config: parameters, services, bindings.config/services_dev.yaml- dev overlay (stub binding).src/feed.gb-FeedClientinterface + two implementations.src/consumer.gb- the autowired consumer that the YAML registers asapp.feed.src/controllers.gb- HTTP controller exposing/feed.main.gb- entry point.
See chapter services.yaml in the manual for the full reference.
Files
Main
services_yaml/main.gb
A runnable Geblang example.
Consumer
services_yaml/src/consumer.gb
A runnable Geblang example.
Controllers
services_yaml/src/controllers.gb
A runnable Geblang example.
Feed
services_yaml/src/feed.gb
A runnable Geblang example.
services_yaml dev overlay
services_yaml/tests/dev_overlay_test.gb
GEBWEB_ENV=dev binds FeedClient -> StubFeedClient and