52 lines
2.7 KiB
Markdown
52 lines
2.7 KiB
Markdown
# example.com/managed
|
|
|
|
This checked-in example uses a relative local framework replacement (`../..`).
|
|
Run `go mod tidy && go run .` here. No external database or cloud account is required.
|
|
The Go-only error catalog is `internal/apierrors/catalog.go`, registered by svc.
|
|
The generated main and handlers are unmodified. Built-in endpoint switches and
|
|
paths are configured in etc/config.yaml under server.endpoints. Health replies
|
|
use the project envelope by default; responseMode: raw opts out. Readiness
|
|
failures stay HTTP 503, independently of business error status policies.
|
|
|
|
Dependencies can call svc.RequestShutdown(err); the generated entry drains
|
|
requests, closes resources and retains the failure for a nonzero exit.
|
|
Try:
|
|
|
|
```sh
|
|
curl -i 'http://127.0.0.1:8080/check?kind=fixed'
|
|
curl -i 'http://127.0.0.1:8080/check?kind=params'
|
|
curl -i 'http://127.0.0.1:8080/missing'
|
|
curl -i -H 'X-Signature: valid' --data-binary ' {"hello":1} ' http://127.0.0.1:8080/callback
|
|
curl -i -F 'file=hello' http://127.0.0.1:8080/upload
|
|
curl -OJ http://127.0.0.1:8080/download
|
|
```
|
|
|
|
The upload demonstration caps requests at 2048 bytes, so use a small test file;
|
|
large input is intentionally rejected with HTTP 413. Replace the demonstration
|
|
`X-Signature` check with the actual provider's signature algorithm and secret.
|
|
From the framework root, check generated files with:
|
|
`go run ./cmd/go-omni api generate --dir examples/managedService --check`.
|
|
|
|
Contract changes produce REVIEW notices for affected Logic methods and DTO fields.
|
|
Definite Logic signature problems produce ERROR diagnostics with a file/line and
|
|
the required signature. Regeneration preserves business code; `--check` continues
|
|
to fail on unresolved signature errors after generation. Run `go test ./...` too,
|
|
especially for project type aliases, build tags and changes inside method bodies.
|
|
|
|
|
|
## Framework-managed runtime
|
|
|
|
`main.go`, `internal/svc/runtimeGen.go`, generated handlers, `internal/types/*Gen.go`
|
|
and OpenAPI are generator-owned. Add project dependencies in `svc.Init(ctx)` and
|
|
register each successful initialization with `OnClose`. Runtime owns reverse
|
|
cleanup and failure rollback; do not copy locks, constructors or Close methods
|
|
into this project. The logger is scoped to this App.
|
|
|
|
Configuration, API contracts, svc fields/Init/AppOptions, Logic, Repository and
|
|
middleware implementations remain developer-owned. Regeneration preserves them.
|
|
Use `go-omni api format` to format local contracts, then `api generate` and
|
|
`api generate --check`. See the [framework development guide](../../DEVELOPMENT.md)
|
|
for array/null responses, typed multipart, full configuration environment overrides,
|
|
shared contracts and v0.13 upgrade steps. This example keeps its raw callback,
|
|
streaming upload and download to exercise those existing extension points.
|