rest

package
v1.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 3, 2023 License: MIT Imports: 1 Imported by: 0

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

func NewActionResponseError

func NewActionResponseError(err error) (res *ActionResponse)

NewActionResponseError with error

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 (*BaseRestResponse) SetError

func (res *BaseRestResponse) SetError(err error)

SetError sets error message

type EntitiesResponse

type EntitiesResponse struct {
	BaseRestResponse
	Page     int      `json:"page"`     // Current page (Bulk) number
	PageSize int      `json:"pageSize"` // 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     []Entity `json:"list"`     // List of objects in the current result set
}

EntitiesResponse message is returned for any action returning multiple entities

func NewEntitiesResponse

func NewEntitiesResponse(entities []Entity, page, pageSize, total int) *EntitiesResponse

NewEntitiesResponse factory method

func NewEntitiesResponseError

func NewEntitiesResponseError(err error) *EntitiesResponse

NewEntitiesResponseError with error

type EntityResponse

type EntityResponse struct {
	BaseRestResponse
	Entity Entity `json:"entity"` // The entity
}

EntityResponse message is returned for any create/update action on entity

func NewEntityResponse

func NewEntityResponse(entity Entity) (er *EntityResponse)

NewEntityResponse factory method

func NewEntityResponseError

func NewEntityResponseError(err error) (res *EntityResponse)

NewEntityResponseError with error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL