feat: add dependency shutdown and configurable service endpoints

This commit is contained in:
2026-09-24 18:33:24 +08:00
parent 8a348951eb
commit f0991d3ff2
51 changed files with 1433 additions and 73 deletions

View File

@@ -16,6 +16,9 @@ type Result struct {
Err error
BusinessCode any
Failed bool
// PreserveStatus keeps an explicit protocol status through catalog mapping
// and HTTP output (for example, readiness must remain 503 when unhealthy).
PreserveStatus bool
}
// IsError preserves failure semantics independently of the HTTP status.

View File

@@ -17,10 +17,14 @@ type errorEncoder struct {
func (e *errorEncoder) ErrorRegistry() *apierrors.Registry { return e.registry }
func (e *errorEncoder) Encode(r Result) (Payload, error) {
status := r.Status
if r.Err != nil {
err := e.registry.Resolve(r.Err)
r.Status, r.Code, r.Message, r.BusinessCode, r.Failed = err.Status, err.Code, err.Message, err.BusinessCode, true
}
if r.PreserveStatus {
r.Status = status
}
return e.next.Encode(r)
}