Documentation
¶
Index ¶
Constants ¶
View Source
const ( DefaultCodeInternal = 1 DefaultCodeUnknown = 2 DefaultCodeUnknownMessage = "unknown error" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Configuration ¶
type Configuration struct { Type ResultType `json:"type" yaml:"type"` // contains filtered or unexported fields }
Configuration is a component for library.
var Config *Configuration
Config is a singleton instance for library.
func (*Configuration) After ¶
func (o *Configuration) After() error
type Error ¶
Error is a component used to define an error struct.
func (Error) GetMessage ¶
type ErrorGetter ¶
Error is a component used to define an error struct.
type Paginator ¶
type Paginator struct { Body any `json:"body" xml:"body"` Paging *Paging `json:"paging" xml:"paging"` }
Paginator is a paginator struct for response.
{ "body": [ { ... }, { ... } ], "paging": { ... } }
type Paging ¶
type Paging struct { // Total // is total amount of items. Total int64 `json:"total" xml:"total"` // Size // show items amount on each page. Size int `json:"size" xml:"size"` // First // shows the start page number of paginator. First int `json:"first" xml:"first"` // Prev // shows previous page number of paginator. Prev int `json:"prev" xml:"prev"` // Curr // shows the current page number of paginator. Curr int `json:"curr" xml:"curr"` // Next // shows the next page number of paginator. Next int `json:"next" xml:"next"` // Last // shows the last page number of paginator. Last int `json:"last" xml:"last"` }
Paging is a component used to store paginator.
type Result ¶
type Result interface { IsHtml() bool IsString() bool // String // convert result as JSON string. String() string // With // generate response as normal with any on data field. With(data any) Result // WithCodeError // generate response as error with specified code and message. WithCodeError(code int, message string) Result // WithEmpty // generate response a simple struct without data field. WithEmpty() Result // WithError // generate response as error struct. WithError(err error) Result // WithHtml // generate response as error struct. WithHtml(body []byte) Result // WithList // generate response as listing on data field. WithList(items any) Result // WithPaging // generate response as paging with a paginator fields on data field. WithPaging(items any, total int64, page, size int) Result // WithString // generate response as string result. WithString(str string) Result }
Result is a standard response operations.
type ResultConstructor ¶
type ResultConstructor func() Result
ResultConstructor is a function used to creates a Result constructor.
type ResultType ¶
type ResultType string
ResultType is a type name for response struct.
const ( ResultTypeCode ResultType = "code" ResultTypeErrno ResultType = "errno" DefaultResultType = ResultTypeErrno )
Source Files
¶
Click to show internal directories.
Click to hide internal directories.