Documentation ¶
Index ¶
- Constants
- type Context
- func (c *Context) ResultError(errorCode int, description string, params ...interface{}) Result
- func (c *Context) ResultNotFound(errorCode int, description string, params ...interface{}) Result
- func (c *Context) ResultSuccess() Result
- func (c *Context) ResultUnauthorized() Result
- func (c *Context) Unexpected(err error, data ...interface{}) Result
- func (c *Context) WithLogger() *Context
- type LangType
- type Result
- type ResultError
- type ResultState
Constants ¶
View Source
const ( LangUS = "en-US" LangBR = "pt-BR" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct { LoggedAuth domains.Auth CID string `json:"cid"` HTTPPrefix string Logger *log.Entry Version string Localizer *i18n.Localizer Lang LangType HostURL string `json:"host_url"` }
Context .
func (*Context) ResultError ¶
ResultError build a common struct for validation error result.
func (*Context) ResultNotFound ¶
ResultNotFound when any record was not found
func (*Context) ResultSuccess ¶
ResultSuccess build a common struct for success.
func (*Context) ResultUnauthorized ¶
ResultUnauthorized Unauthorized
func (*Context) Unexpected ¶
Unexpected build a struct for unexpected error result.
func (*Context) WithLogger ¶
WithLogger add logger to context.
type Result ¶
type Result struct { State ResultState Error error ErrorCode int ErrorDescription string }
Result is a struct of result.
type ResultError ¶
type ResultError struct { Code int `json:"error_code"` Description string `json:"error_description"` }
ResultError base struct for application errors.
type ResultState ¶
type ResultState int
ResultState represent actual state of result.
const ( // ResultStateSuccess state is when the result is ok. ResultStateSuccess ResultState = 0 // ResultStateError state is when the result has validation error. ResultStateError ResultState = 1 // ResultStateUnexpected state is when the result has unexpected error. ResultStateUnexpected ResultState = 2 // ResultStateNotFound when a register was not found ResultStateNotFound ResultState = 3 ResultStateUnauthorized ResultState = 4 )
Click to show internal directories.
Click to hide internal directories.