Release - v1.37.1
🚀 Improvements
Extended Error Responses (RFC 9457-style)
-
GoFr now supports extended error responses following the RFC 9457 specification.
-
Developers can implement the new
ResponseMarshaler
interface to enrich error responses with custom fields beyond the standard error message and status code.type ResponseMarshaler interface { Response() map[string]any }
-
Example:
type ValidationError struct { Field string Message string Code int } func (e ValidationError) Error() string { return e.Message } func (e ValidationError) StatusCode() int { return e.Code } func (e ValidationError) Response() map[string]any { return map[string]any{ "field": e.Field, "type": "validation_error", "details": "Invalid input format", } }
⚠️ Note: Themessage
field is automatically populated from theError()
method. Custom fields with the name "message" in theResponse()
map should not be used as they will be ignored in favor of theError()
value.This feature allows more descriptive and structured error responses, ideal for client-side validation, API debugging, and frontend integration.
🛠 Fixes
1. WebSocket: Fixed Concurrent Write Panic
- WebSocket writes are now thread-safe. Previously, concurrent calls to
WriteMessageToSocket()
caused race conditions and panics. Writes are now internally synchronized.
2. NATS: Synchronous Connection Setup
- NATS connections are now established synchronously to prevent
errJetStreamNotConfigured
errors when callingjetStream()
immediately afterConnect()
.