response

package
v0.4.24 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2023 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NO_DATA_FOUND = "NO-DATA-FOUND"
)

Variables

This section is empty.

Functions

func GetDescFromCode added in v0.3.21

func GetDescFromCode(code string, data any, errDescList map[string]string) (string, any)

func JustPrintResp

func JustPrintResp(respBytes []byte, desc string, status int) (int, map[string]string, any, error)

func ParseRemoteRespJson

func ParseRemoteRespJson(respBytes []byte, desc string, status int) (int, map[string]string, any, error)

func ParseWsRemoteResp

func ParseWsRemoteResp(respBytes []byte, desc string, status int) (int, map[string]string, any, error)

Types

type DbResponse

type DbResponse struct {
	Status      int    `json:"status"`
	Description string `json:"description"`
	Result      any    `json:"result"`
	ErrorCode   string `json:"error_code,omitempty"`
}

type ErrorResponse

type ErrorResponse struct {
	Code        string `json:"code"`
	Description any    `json:"description"`
}

func FormatErrorResp

func FormatErrorResp(errs error, trans ut.Translator) []ErrorResponse

func GetErrorsArray

func GetErrorsArray(message string, data any) []ErrorResponse

func GetErrorsArrayWithMap

func GetErrorsArrayWithMap(incomingDesc string, data any, errDescList map[string]string) []ErrorResponse

type ErrorState

type ErrorState struct {
	Source      string
	Input       any
	ErrorDesc   string
	Status      int
	Description string
	Message     any
	Child       error
}

func Error

func Error(status int, desc string, message any, err error) *ErrorState

func ToError

func ToError(desc string, message any, err error) *ErrorState

func ToErrorState

func ToErrorState(err error) *ErrorState

func (ErrorState) AddInput added in v0.3.1

func (e ErrorState) AddInput(in any) *ErrorState

func (ErrorState) AddSource added in v0.3.1

func (e ErrorState) AddSource(src string) *ErrorState

func (ErrorState) Error

func (e ErrorState) Error() string

func (ErrorState) WsResponse

func (e ErrorState) WsResponse() string

type InternalError

type InternalError struct {
	Desc    string
	Message any
}

func (InternalError) Error

func (e InternalError) Error() string

type Receipt

type Receipt struct {
	Id    string `json:"id"`
	Title string `json:"title"`
	Rows  []any  `json:"rows"`
}

type ResponseHandler

type ResponseHandler interface {
	GetErrorsArray(message string, data any) []ErrorResponse
	HandleErrorState(err error, status int, message string, data any, ctx any)
	Respond(code, status int, message string, data any, abort bool, ctx any)
	RespondWithReceipt(code, status int, message string, data any, printData *Receipt, abort bool, ctx any)
}

type WsRemoteResponse

type WsRemoteResponse struct {
	Status      int             `json:"status"`
	Description string          `json:"description"`
	Result      any             `json:"result,omitempty"`
	ErrorData   []ErrorResponse `json:"errors,omitempty"`
}

func (WsRemoteResponse) ToErrorState added in v0.1.7

func (e WsRemoteResponse) ToErrorState() *ErrorState

type WsResponse

type WsResponse struct {
	Status       int      `json:"status"`
	Description  string   `json:"description"`
	Result       any      `json:"result,omitempty"`
	ErrorData    any      `json:"errors,omitempty"`
	PrintReceipt *Receipt `json:"printReceipt,omitempty"`
}

Jump to

Keyboard shortcuts

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