20 lines
458 B
Go
20 lines
458 B
Go
package libshared
|
|
|
|
import "time"
|
|
|
|
type APIResponse[T any] struct {
|
|
Timestamp int64 `json:"timestamp"`
|
|
Status string `json:"status"` // "success" or "fail"
|
|
Message string `json:"message"`
|
|
Content T `json:"content,omitempty"`
|
|
}
|
|
|
|
func NewAPIResponse[T any](status string, message string, response T) APIResponse[T] {
|
|
return APIResponse[T]{
|
|
Timestamp: time.Now().Unix(),
|
|
Status: status,
|
|
Message: message,
|
|
Content: response,
|
|
}
|
|
}
|