Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActionResponse ¶
type ActionResponse struct {
BaseRestResponse
Key string `json:"key,omitempty"` // The entity key (Id)
Data string `json:"data,omitempty"` // Additional data
}
ActionResponse message is returned for any action on entity with no return data (e.d. delete)
func NewActionResponse ¶
func NewActionResponse(key, data string) (er *ActionResponse)
NewActionResponse factory method
type BaseRestResponse ¶
type BaseRestResponse struct {
Code int `json:"code"` // Error code (0 for success)
Error string `json:"error,omitempty"` // Error message
}
BaseRestResponse is a common structure for all response types
func NewErrorResponse ¶ added in v1.2.19
func NewErrorResponse(err error) (res *BaseRestResponse)
NewErrorResponse response with error
func NewErrorResponseWithCode ¶ added in v1.2.152
func NewErrorResponseWithCode(code int, err error) (res *BaseRestResponse)
NewErrorResponseWithCode response with error and customized code
func (*BaseRestResponse) SetError ¶
func (res *BaseRestResponse) SetError(err error)
SetError sets error message
func (*BaseRestResponse) SetErrorWithCode ¶ added in v1.2.152
func (res *BaseRestResponse) SetErrorWithCode(code int, err error)
SetErrorWithCode sets an error message with customized code (must be negative)
type EntitiesRequest ¶ added in v1.2.150
type EntitiesRequest[T Entity] struct {
List []T `json:"list"` // List of objects in the current result set
}
EntitiesRequest message is returned for any action returning multiple entities
func NewEntitiesRequest ¶ added in v1.2.150
func NewEntitiesRequest[T Entity](entities []T, page, size, total int) *EntitiesRequest[T]
NewEntitiesRequest factory method
type EntitiesResponse ¶
type EntitiesResponse[T Entity] struct {
BaseRestResponse
Page int `json:"page"` // Current page (Bulk) number
Size int `json:"size"` // Size of page (items in bulk)
Pages int `json:"pages"` // Total number of pages
Total int `json:"total"` // Total number of items in the query
List []T `json:"list"` // List of objects in the current result set
}
EntitiesResponse message is returned for any action returning multiple entities
func NewEntitiesResponse ¶
func NewEntitiesResponse[T Entity](entities []T, page, size, total int) *EntitiesResponse[T]
NewEntitiesResponse factory method
type EntityRequest ¶ added in v1.2.150
type EntityRequest[T Entity] struct {
Entity T `json:"entity"` // The entity
}
EntityRequest message is returned for any create/update action on entity
func NewEntityRequest ¶ added in v1.2.150
func NewEntityRequest[T Entity](entity T) (er *EntityRequest[T])
NewEntityRequest factory method
type EntityResponse ¶
type EntityResponse[T Entity] struct {
BaseRestResponse
Entity T `json:"entity"` // The entity
}
EntityResponse message is returned for any create/update action on entity
func NewEntityResponse ¶
func NewEntityResponse[T Entity](entity T) (er *EntityResponse[T])
NewEntityResponse factory method