Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Body ¶
type Body struct {
Success bool `json:"success"`
Timestamp time.Time `json:"timestamp,omitempty"`
Message string `json:"message,omitempty"`
Errors []Error `json:"errors,omitempty"`
Data interface{} `json:"data,omitempty"`
}
Body defines standard HTTP body body.
func (*Body) GetErrors ¶
GetErrors returns the HTTP Response Body's errors and whether it's exist or not.
func (*Body) GetMessage ¶
GetMessage returns the HTTP Response Body's message and whether it's exist or not.
type Builder ¶
type Builder interface {
// AppendError add an error to HTTP Response Body.
AppendError(code int64, reason string) Builder
// AppendErrors add multiple errors to HTTP Response Body.
AppendErrors(errors ...Error) Builder
// Build returns the HTTP Response Body.
Build() Body
// Clean all the information set to HTTP Response Body.
Clean() Builder
// SetData set the HTTP Response Body's Data.
SetData(data interface{}) Builder
// SetErrors set the HTTP Response Body's Errors.
SetErrors(errors ...Error) Builder
// SetMessage set the HTTP Response Body's Message.
SetMessage(message string) Builder
// SetStatusCode set the status code of HTTP Response.
SetStatusCode(statusCode int) Builder
// Send the HTTP Response via the SendFunc callback provided.
Send(callback SendFunc) error
// Write the HTTP Response to the http.ResponseWriter.
Write(writer http.ResponseWriter) (int, error)
}
Builder defines methods to build HTTP Response Body.
Click to show internal directories.
Click to hide internal directories.