initial commit
This commit is contained in:
19
apiresponse.go
Normal file
19
apiresponse.go
Normal file
@@ -0,0 +1,19 @@
|
||||
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,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user