Documentation ¶
Index ¶
- Constants
- func AbortWithCodeErr(c echo.Context, code int, err error)
- func AcquireBuffer() *bytes.Buffer
- func Bind(c echo.Context, v interface{}, flag int) (err error)
- func BindHeader(c echo.Context, v interface{}) error
- func BindParam(c echo.Context, v interface{}) error
- func CodeMsg(code int) string
- func CtxDebug(ec *Context, format string, args ...interface{})
- func CtxDebugKV(ec *Context, msg string, fields ...zap.Field)
- func CtxError(ec *Context, format string, args ...interface{})
- func CtxErrorKV(ec *Context, msg string, fields ...zap.Field)
- func CtxFatal(ec *Context, format string, args ...interface{})
- func CtxFatalKV(ec *Context, msg string, fields ...zap.Field)
- func CtxInfo(ec *Context, format string, args ...interface{})
- func CtxInfoKV(ec *Context, msg string, fields ...zap.Field)
- func CtxPanic(ec *Context, format string, args ...interface{})
- func CtxPanicKV(ec *Context, msg string, fields ...zap.Field)
- func CtxWarn(ec *Context, format string, args ...interface{})
- func CtxWarnKV(ec *Context, msg string, fields ...zap.Field)
- func Debug(format string, args ...interface{})
- func DebugKV(msg string, fields ...zap.Field)
- func EncodeJSON(v interface{}) (*bytes.Buffer, error)
- func EncodeValues(v interface{}) (url.Values, error)
- func Error(format string, args ...interface{})
- func ErrorKV(msg string, fields ...zap.Field)
- func FasterJSONReflectedEncoder(w io.Writer) zapcore.ReflectedEncoder
- func Fatal(format string, args ...interface{})
- func FatalKV(msg string, fields ...zap.Field)
- func FinishWithCodeData(c echo.Context, code int, data interface{})
- func FlushLog() error
- func ForceRegisterCode(code int, msg string, status int)
- func FormBindBody(c echo.Context, v interface{}) error
- func FormBindQuery(c echo.Context, v interface{}) error
- func FormBindQueryBody(c echo.Context, v interface{}) error
- func FormBool(c echo.Context, key string) (bool, error)
- func FormInt64(c echo.Context, key string) (int64, error)
- func FormString(c echo.Context, key string) (string, error)
- func FormUint64(c echo.Context, key string) (uint64, error)
- func GetHostname() (host string)
- func GetRequestHost(req *http.Request) (host string)
- func GetRequestID(c echo.Context) string
- func GetUUID(c echo.Context) (u string)
- func HTTPStatus(code int) int
- func HeaderBool(c echo.Context, key string) (bool, error)
- func HeaderInt64(c echo.Context, key string) (int64, error)
- func HeaderString(c echo.Context, key string) (string, error)
- func HeaderUint64(c echo.Context, key string) (uint64, error)
- func Info(format string, args ...interface{})
- func InfoKV(msg string, fields ...zap.Field)
- func IsEchotoolError(err error) bool
- func IsEmptyError(err error) bool
- func JSONBindBody(c echo.Context, v interface{}) error
- func MsgpackBindBody(c echo.Context, v interface{}) error
- func MustBind(c echo.Context, v interface{}, flag int, cbs ...CallbackFunc)
- func MustBindHeader(c echo.Context, v interface{}, cbs ...CallbackFunc)
- func MustBindParam(c echo.Context, v interface{}, cbs ...CallbackFunc)
- func MustDo(run RunFunc, codes ...int) interface{}
- func MustDoCallback(run RunFunc, code int, cbs ...CallbackFunc) interface{}
- func MustEncodeJSON(v interface{}, cbs ...CallbackFunc) *bytes.Buffer
- func MustEncodeValues(v interface{}, cbs ...CallbackFunc) url.Values
- func MustFormBindBody(c echo.Context, v interface{}, cbs ...CallbackFunc)
- func MustFormBindQuery(c echo.Context, v interface{}, cbs ...CallbackFunc)
- func MustFormBindQueryBody(c echo.Context, v interface{}, cbs ...CallbackFunc)
- func MustFormBool(c echo.Context, key string, cbs ...CallbackFunc) bool
- func MustFormInt64(c echo.Context, key string, cbs ...CallbackFunc) int64
- func MustFormString(c echo.Context, key string, cbs ...CallbackFunc) string
- func MustFormUint64(c echo.Context, key string, cbs ...CallbackFunc) uint64
- func MustHeaderBool(c echo.Context, key string, cbs ...CallbackFunc) bool
- func MustHeaderInt64(c echo.Context, key string, cbs ...CallbackFunc) int64
- func MustHeaderString(c echo.Context, key string, cbs ...CallbackFunc) string
- func MustHeaderUInt64(c echo.Context, key string, cbs ...CallbackFunc) uint64
- func MustJSONBindBody(c echo.Context, v interface{}, cbs ...CallbackFunc)
- func MustMsgpackBindBody(c echo.Context, v interface{}, cbs ...CallbackFunc)
- func MustParamBool(c echo.Context, key string, cbs ...CallbackFunc) bool
- func MustParamInt64(c echo.Context, key string, cbs ...CallbackFunc) int64
- func MustParamString(c echo.Context, key string, cbs ...CallbackFunc) string
- func MustParamUInt64(c echo.Context, key string, cbs ...CallbackFunc) uint64
- func MustPostFormBool(c echo.Context, key string, cbs ...CallbackFunc) bool
- func MustPostFormInt64(c echo.Context, key string, cbs ...CallbackFunc) int64
- func MustPostFormString(c echo.Context, key string, cbs ...CallbackFunc) string
- func MustPostFormUInt64(c echo.Context, key string, cbs ...CallbackFunc) uint64
- func MustProtobufBindBody(c echo.Context, v interface{}, cbs ...CallbackFunc)
- func MustQueryBool(c echo.Context, key string, cbs ...CallbackFunc) bool
- func MustQueryInt64(c echo.Context, key string, cbs ...CallbackFunc) int64
- func MustQueryString(c echo.Context, key string, cbs ...CallbackFunc) string
- func MustQueryUInt64(c echo.Context, key string, cbs ...CallbackFunc) uint64
- func MustValidate(v interface{}, cbs ...CallbackFunc)
- func MustXMLBindBody(c echo.Context, v interface{}, cbs ...CallbackFunc)
- func MustYAMLBindBody(c echo.Context, v interface{}, cbs ...CallbackFunc)
- func New(c echo.Context, v interface{}) *proxy
- func NewDefaultEcho() *echo.Echo
- func NewDefaultLogger() *zap.SugaredLogger
- func Panic(format string, args ...interface{})
- func PanicKV(msg string, fields ...zap.Field)
- func ParamBool(c echo.Context, key string) (bool, error)
- func ParamInt64(c echo.Context, key string) (int64, error)
- func ParamString(c echo.Context, key string) (string, error)
- func ParamUint64(c echo.Context, key string) (uint64, error)
- func PostFormBool(c echo.Context, key string) (bool, error)
- func PostFormInt64(c echo.Context, key string) (int64, error)
- func PostFormString(c echo.Context, key string) (string, error)
- func PostFormUint64(c echo.Context, key string) (uint64, error)
- func ProtobufBindBody(c echo.Context, v interface{}) error
- func QueryBool(c echo.Context, key string) (bool, error)
- func QueryInt64(c echo.Context, key string) (int64, error)
- func QueryString(c echo.Context, key string) (string, error)
- func QueryUint64(c echo.Context, key string) (uint64, error)
- func RegisterCode(code int, msg string, status int) bool
- func ReleaseBuffer(buffer *bytes.Buffer)
- func ReleaseEchotoolError(e *EchotoolError)
- func SetLogger(l *zap.SugaredLogger)
- func SetRequestID(f func(c echo.Context) string) echo.MiddlewareFunc
- func Validate(v interface{}) error
- func Warn(format string, args ...interface{})
- func WarnKV(msg string, fields ...zap.Field)
- func XMLBindBody(c echo.Context, v interface{}) error
- func YAMLBindBody(c echo.Context, v interface{}) error
- type CallbackFunc
- type CommonResponse
- type Context
- func (ec *Context) Abort(code int, err error)
- func (ec *Context) Finish(code int, data interface{})
- func (ec *Context) GetCode() int
- func (ec *Context) GetCustomValue(key string) (value string, exists bool)
- func (ec *Context) GetCustomValues() map[string]string
- func (ec *Context) GetData() interface{}
- func (ec *Context) GetError() error
- func (ec *Context) GetNamedValue() string
- func (ec *Context) IsOK() bool
- func (ec *Context) SetCustomValue(key, value string)
- func (ec *Context) SetNamedValue(value string)
- func (ec *Context) String() string
- type EchotoolError
- type EmptyError
- type Engine
- type HandlerFunc
- type HandlerFuncsChain
- type Kind
- type Option
- type RunFunc
Constants ¶
const ( BValidator = 1 << iota BHeader BParam BFormQuery BFormBody BFormQueryBody BJSONBody BXMLBody BProtobufBody BMsgpackBody BYAMLBody )
const ( CodeOKZero = 0 CodeOK = 20000 CodeCreated = 20100 CodePartialContent = 20600 CodeMultipleChoices = 30000 CodeMovedPermanently = 30100 CodeFound = 30200 CodeSeeOther = 30300 CodeNotModified = 30400 CodeUseProxy = 30500 CodeTemporaryRedirect = 30700 CodePermanentRedirect = 30800 CodeBadRequest = 40000 CodeForbidden = 40300 CodeNotFound = 40400 CodeTooManyRequests = 42900 CodeValidateErr = 45000 CodeInternalErr = 50000 CodeParseDataErr = 50013 CodeMySQLErr = 50014 CodePostgreSQLErr = 50015 CodeRedisErr = 50016 CodeClickHouseErr = 50017 CodeNSQErr = 50030 CodeKafkaErr = 50031 CodeRocketMQErr = 50032 CodeBindErr = 50040 CodeEncodeErr = 50041 CodeDownstreamErr = 50099 )
const (
KeyRequestID = "x_request_id"
)
const (
UnknownStatus = 999
)
Variables ¶
This section is empty.
Functions ¶
func AcquireBuffer ¶
func BindHeader ¶
BindHeader needs tag "header" in fields of v. The value of tag "header" is automatically converted to the canonical format.
func CtxFatalKV ¶ added in v1.0.3
CtxFatalKV logs a message, then calls os.Exit.
func CtxPanicKV ¶ added in v1.0.3
CtxPanicKV logs a message, then panics.
func EncodeJSON ¶
EncodeJSON needs tag "json" in fields of v. Note: ReleaseBuffer needs to be called after EncodeJSON is called successfully.
func EncodeValues ¶
EncodeValues needs tag "url" in fields of v.
func FasterJSONReflectedEncoder ¶ added in v1.0.3
func FasterJSONReflectedEncoder(w io.Writer) zapcore.ReflectedEncoder
func Fatal ¶ added in v1.0.2
func Fatal(format string, args ...interface{})
Fatal logs a message, then calls os.Exit.
func FinishWithCodeData ¶
func ForceRegisterCode ¶
ForceRegisterCode will force to cover codeMsg map and httpStatus map.
func FormBindBody ¶
FormBindBody needs tag "form" in fields of v.
func FormBindQuery ¶
FormBindQuery needs tag "form" in fields of v.
func FormBindQueryBody ¶
FormBindQueryBody needs tag "form" in fields of v.
func GetHostname ¶ added in v1.0.1
func GetHostname() (host string)
func GetRequestHost ¶
func GetRequestID ¶
func HTTPStatus ¶
func IsEchotoolError ¶
func IsEmptyError ¶
func JSONBindBody ¶
JSONBindBody needs tag "json" in fields of v.
func MsgpackBindBody ¶
MsgpackBindBody needs tag "msgpack" in fields of v.
func MustBindHeader ¶
func MustBindHeader(c echo.Context, v interface{}, cbs ...CallbackFunc)
func MustBindParam ¶
func MustBindParam(c echo.Context, v interface{}, cbs ...CallbackFunc)
func MustDoCallback ¶
func MustDoCallback(run RunFunc, code int, cbs ...CallbackFunc) interface{}
MustDoCallback will call cbs if and only if run has error.
func MustEncodeJSON ¶
func MustEncodeJSON(v interface{}, cbs ...CallbackFunc) *bytes.Buffer
MustEncodeJSON needs tag "json" in fields of v. Note: ReleaseBuffer needs to be called after MustEncodeJSON is called successfully.
func MustEncodeValues ¶
func MustEncodeValues(v interface{}, cbs ...CallbackFunc) url.Values
func MustFormBindBody ¶
func MustFormBindBody(c echo.Context, v interface{}, cbs ...CallbackFunc)
func MustFormBindQuery ¶
func MustFormBindQuery(c echo.Context, v interface{}, cbs ...CallbackFunc)
func MustFormBindQueryBody ¶
func MustFormBindQueryBody(c echo.Context, v interface{}, cbs ...CallbackFunc)
func MustFormBool ¶
func MustFormBool(c echo.Context, key string, cbs ...CallbackFunc) bool
func MustFormInt64 ¶
func MustFormInt64(c echo.Context, key string, cbs ...CallbackFunc) int64
func MustFormString ¶
func MustFormString(c echo.Context, key string, cbs ...CallbackFunc) string
func MustFormUint64 ¶
func MustFormUint64(c echo.Context, key string, cbs ...CallbackFunc) uint64
func MustHeaderBool ¶
func MustHeaderBool(c echo.Context, key string, cbs ...CallbackFunc) bool
func MustHeaderInt64 ¶
func MustHeaderInt64(c echo.Context, key string, cbs ...CallbackFunc) int64
func MustHeaderString ¶
func MustHeaderString(c echo.Context, key string, cbs ...CallbackFunc) string
func MustHeaderUInt64 ¶
func MustHeaderUInt64(c echo.Context, key string, cbs ...CallbackFunc) uint64
func MustJSONBindBody ¶
func MustJSONBindBody(c echo.Context, v interface{}, cbs ...CallbackFunc)
func MustMsgpackBindBody ¶
func MustMsgpackBindBody(c echo.Context, v interface{}, cbs ...CallbackFunc)
func MustParamBool ¶
func MustParamBool(c echo.Context, key string, cbs ...CallbackFunc) bool
func MustParamInt64 ¶
func MustParamInt64(c echo.Context, key string, cbs ...CallbackFunc) int64
func MustParamString ¶
func MustParamString(c echo.Context, key string, cbs ...CallbackFunc) string
func MustParamUInt64 ¶
func MustParamUInt64(c echo.Context, key string, cbs ...CallbackFunc) uint64
func MustPostFormBool ¶
func MustPostFormBool(c echo.Context, key string, cbs ...CallbackFunc) bool
func MustPostFormInt64 ¶
func MustPostFormInt64(c echo.Context, key string, cbs ...CallbackFunc) int64
func MustPostFormString ¶
func MustPostFormString(c echo.Context, key string, cbs ...CallbackFunc) string
func MustPostFormUInt64 ¶
func MustPostFormUInt64(c echo.Context, key string, cbs ...CallbackFunc) uint64
func MustProtobufBindBody ¶
func MustProtobufBindBody(c echo.Context, v interface{}, cbs ...CallbackFunc)
func MustQueryBool ¶
func MustQueryBool(c echo.Context, key string, cbs ...CallbackFunc) bool
func MustQueryInt64 ¶
func MustQueryInt64(c echo.Context, key string, cbs ...CallbackFunc) int64
func MustQueryString ¶
func MustQueryString(c echo.Context, key string, cbs ...CallbackFunc) string
func MustQueryUInt64 ¶
func MustQueryUInt64(c echo.Context, key string, cbs ...CallbackFunc) uint64
func MustValidate ¶
func MustValidate(v interface{}, cbs ...CallbackFunc)
func MustXMLBindBody ¶
func MustXMLBindBody(c echo.Context, v interface{}, cbs ...CallbackFunc)
func MustYAMLBindBody ¶
func MustYAMLBindBody(c echo.Context, v interface{}, cbs ...CallbackFunc)
func NewDefaultEcho ¶ added in v1.0.3
func NewDefaultLogger ¶ added in v1.0.1
func NewDefaultLogger() *zap.SugaredLogger
func Panic ¶ added in v1.0.2
func Panic(format string, args ...interface{})
Panic logs a message, then panics.
func ProtobufBindBody ¶
ProtobufBindBody needs tag "protobuf" in fields of v.
func RegisterCode ¶
RegisterCode will not cover code and status which exists.
func ReleaseBuffer ¶
func ReleaseEchotoolError ¶
func ReleaseEchotoolError(e *EchotoolError)
func SetLogger ¶ added in v1.0.1
func SetLogger(l *zap.SugaredLogger)
func SetRequestID ¶
func SetRequestID(f func(c echo.Context) string) echo.MiddlewareFunc
func XMLBindBody ¶
XMLBindBody needs tag "xml" in fields of v.
func YAMLBindBody ¶
YAMLBindBody needs tag "yaml" in fields of v.
Types ¶
type CallbackFunc ¶
type CallbackFunc func(error)
type CommonResponse ¶
type CommonResponse struct { RequestID string `json:"request_id,omitempty"` Code int `json:"code"` Message string `json:"message"` Data interface{} `json:"data,omitempty"` }
func RespOK ¶
func RespOK(id string, code int, data interface{}) *CommonResponse
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
func (*Context) GetCustomValue ¶ added in v1.0.1
func (*Context) GetCustomValues ¶ added in v1.0.1
func (*Context) GetNamedValue ¶ added in v1.0.1
func (*Context) SetCustomValue ¶ added in v1.0.1
func (*Context) SetNamedValue ¶ added in v1.0.1
type EchotoolError ¶
type EchotoolError struct {
// contains filtered or unexported fields
}
func AcquireEchotoolError ¶
func AcquireEchotoolError(code int, err error) (e *EchotoolError)
func (EchotoolError) Error ¶
func (e EchotoolError) Error() string
func (EchotoolError) GetCode ¶
func (e EchotoolError) GetCode() int
func (EchotoolError) GetError ¶
func (e EchotoolError) GetError() error
type EmptyError ¶
type EmptyError struct {
// contains filtered or unexported fields
}
func NewEmptyError ¶
func NewEmptyError(kind Kind, key string) *EmptyError
func NewFormEmptyError ¶
func NewFormEmptyError(key string) *EmptyError
func NewHeaderEmptyError ¶
func NewHeaderEmptyError(key string) *EmptyError
func NewParamEmptyError ¶
func NewParamEmptyError(key string) *EmptyError
func NewPostFormEmptyError ¶
func NewPostFormEmptyError(key string) *EmptyError
func NewQueryEmptyError ¶
func NewQueryEmptyError(key string) *EmptyError
func (EmptyError) Error ¶
func (e EmptyError) Error() string
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func NewDefaultEngine ¶ added in v1.0.3
func (*Engine) EchoHandler ¶
func (e *Engine) EchoHandler(handlers ...HandlerFunc) echo.HandlerFunc
func (*Engine) Use ¶
func (e *Engine) Use(middlewares ...HandlerFunc) *Engine
type HandlerFunc ¶
func AddNotice ¶ added in v1.0.1
func AddNotice(key, value string) HandlerFunc
AddNotice adds kv pair to log for troubleshooting problems and so on.
func AddTraceID ¶ added in v1.0.1
func AddTraceID(f func(c echo.Context) string) HandlerFunc
AddTraceID adds trace id to log for troubleshooting problems and so on.
func GetCommonAborter ¶
func GetCommonAborter() HandlerFunc
func GetCommonFinisher ¶
func GetCommonFinisher() HandlerFunc
type HandlerFuncsChain ¶
type HandlerFuncsChain []HandlerFunc
type Option ¶
type Option func(*Engine)
func WithAborter ¶
func WithAborter(aborter HandlerFunc) Option
func WithFinisher ¶
func WithFinisher(finisher HandlerFunc) Option