Refactor API Response Structure to Use Inline Data Field
- Updated the APIResponse struct to change the Data field to use inline JSON representation, enhancing the response format. - Removed the Meta field from the SuccessWithMeta function, simplifying the success response handling. - This change improves the clarity and consistency of API responses, aligning with best practices for response structures.
This commit is contained in:
@@ -12,9 +12,8 @@ import (
|
||||
type APIResponse struct {
|
||||
Success bool `json:"success"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Data interface{} `json:"data,omitempty"`
|
||||
Data interface{} `json:",inline"`
|
||||
Error *APIError `json:"error,omitempty"`
|
||||
Meta *Meta `json:"meta,omitempty"`
|
||||
}
|
||||
|
||||
// APIError represents error details in API response
|
||||
@@ -55,7 +54,6 @@ func SuccessWithMeta(c echo.Context, data interface{}, meta *Meta, message strin
|
||||
Success: true,
|
||||
Message: message,
|
||||
Data: data,
|
||||
Meta: meta,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user