feat: add dependency shutdown and configurable service endpoints
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user