Skip to content

v1.37.1

Latest
Compare
Choose a tag to compare
@aryanmehrotra aryanmehrotra released this 16 Apr 04:13
d969729

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: The message field is automatically populated from the Error() method. Custom fields with the name "message" in the Response() map should not be used as they will be ignored in favor of the Error() 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 calling jetStream() immediately after Connect().