result

package
v0.0.0-...-de3cd48 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StatusIs

func StatusIs(result *Result, status ecode.Status) bool

StatusIs ...

Types

type Option

type Option func(r *Result)

func Caller

func Caller(caller string) Option

Caller caller

func HttpCode

func HttpCode(code int) Option

HttpCode http code

func Level

func Level(level log.Level) Option

Level log level

func Message

func Message(msg string) Option

Message msg

func RenderType

func RenderType(renderTyp RenderTyp) Option

RenderType render type

func UseStatusMsg

func UseStatusMsg() Option

UseStatusMsg use status msg

type RenderTyp

type RenderTyp string
const (
	JSON RenderTyp = "JSON"
	HTML RenderTyp = "HTML"
	TEXT RenderTyp = "TEXT"
)

type Result

type Result struct {
	Status ecode.Status `json:"status"`
	Msg    string       `json:"message"`
	Data   interface{}  `json:"data"`
	// contains filtered or unexported fields
}

func FromRPCError

func FromRPCError(err error, opts ...Option) *Result

FromRPCError ...

func New

func New(status ecode.Status, data interface{}, opts ...Option) *Result

New ...

func (*Result) Caller

func (r *Result) Caller() string

Caller ...

func (*Result) HttpCode

func (r *Result) HttpCode() int

HttpCode ...

func (*Result) Level

func (r *Result) Level() log.Level

Level ...

func (*Result) RenderType

func (r *Result) RenderType() RenderTyp

RenderType ...

func (*Result) StatusIs

func (r *Result) StatusIs(status ecode.Status) bool

StatusIs ...

func (*Result) StatusIsNotFound

func (r *Result) StatusIsNotFound(status ecode.Status) bool

StatusIsNotFound ...

Jump to

Keyboard shortcuts

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