Files
MyGoServer/internal/apiserver/models/response.go

26 lines
599 B
Go

package models
// Response represents a standard API response
type Response struct {
Success bool `json:"success"`
Data interface{} `json:"data,omitempty"`
Error string `json:"error,omitempty"`
RequestID string `json:"request_id,omitempty"`
}
// NewSuccessResponse creates a successful response
func NewSuccessResponse(data interface{}) *Response {
return &Response{
Success: true,
Data: data,
}
}
// NewErrorResponse creates an error response
func NewErrorResponse(err error) *Response {
return &Response{
Success: false,
Error: err.Error(),
}
}