web

package
v0.0.0-...-b08fcc5 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2023 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderXTraceID         = "X-Trace-Id"
	DaeBaggageHeaderPrefix = "daectx-"
)

Variables

View Source
var Lang map[string]map[int32]string

Functions

func GlobalTrace

func GlobalTrace() echo.MiddlewareFunc

func Init

func Init(initializers ...Initializer)

func RequestLogger

func RequestLogger() echo.MiddlewareFunc

RequestLogger 请求日志

Types

type Context

type Context struct {
	echo.Context
}

func (*Context) BindValidParams

func (c *Context) BindValidParams(req interface{}) (err error)

BindValidParams 绑定参数+验证

func (*Context) CustomFailMsg

func (c *Context) CustomFailMsg(err error, code int, msg string) error

CustomFailMsg 自定义错误返回

func (*Context) Fail

func (c *Context) Fail(err error, data ...interface{}) error

func (*Context) FailWithArray

func (c *Context) FailWithArray(err error) error

FailWithArray data为[]

func (*Context) FailWithObject

func (c *Context) FailWithObject(err error) error

FailWithObject data为{}

func (*Context) FailWithString

func (c *Context) FailWithString(err error) error

FailWithString data为空字符串

func (*Context) Paginated

func (c *Context) Paginated(page page.Page) error

func (*Context) Pagination

func (c *Context) Pagination() paging.Pageable

func (*Context) RequestId

func (c *Context) RequestId() string

func (*Context) Success

func (c *Context) Success(data ...interface{}) error

func (*Context) TODO

func (c *Context) TODO() ctx.Context

func (*Context) TraceId

func (c *Context) TraceId() string

func (*Context) ValidateFieldErrors

func (c *Context) ValidateFieldErrors(handler interface{}) *errors.FieldErrors

func (*Context) WithValue

func (c *Context) WithValue(key string, val interface{})

type Group

type Group interface {
	GET(path string, handler HandlerFunc, middleware ...MiddlewareFunc)
	POST(path string, handler HandlerFunc, middleware ...MiddlewareFunc)
	PUT(path string, handler HandlerFunc, middleware ...MiddlewareFunc)
	DELETE(path string, handler HandlerFunc, middleware ...MiddlewareFunc)
	HEAD(path string, handler HandlerFunc, middleware ...MiddlewareFunc)
	PATCH(path string, handler HandlerFunc, middleware ...MiddlewareFunc)
	Group(prefix string, middleware ...MiddlewareFunc) Group
}

type Handler

type Handler interface {
	Handle(router Router)
}

type HandlerFunc

type HandlerFunc func(Context) error

type Initializer

type Initializer func() error

type MiddlewareFunc

type MiddlewareFunc func(Context) error

type Pagination

type Pagination struct {
	Page  int32 `json:"page"`
	Size  int32 `json:"size"`
	Total int32 `json:"total"`
}

type Response

type Response struct {
	Code       int                `json:"code"`
	Message    string             `json:"message"`
	Data       interface{}        `json:"data"`
	Errors     errors.FieldErrors `json:"errors,omitempty"`
	Path       string             `json:"path"`
	TraceID    string             `json:"trace_id,omitempty"`
	Pagination *Pagination        `json:"pagination,omitempty"`
}

type Router

type Router interface {
	GET(path string, handler HandlerFunc, middleware ...MiddlewareFunc)
	POST(path string, handler HandlerFunc, middleware ...MiddlewareFunc)
	PUT(path string, handler HandlerFunc, middleware ...MiddlewareFunc)
	DELETE(path string, handler HandlerFunc, middleware ...MiddlewareFunc)
	HEAD(path string, handler HandlerFunc, middleware ...MiddlewareFunc)
	PATCH(path string, handler HandlerFunc, middleware ...MiddlewareFunc)
	Group(prefix string, middleware ...MiddlewareFunc) Group
	Static(prefix, root string)
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(srvName string) *Service

func (*Service) Client

func (s *Service) Client() client.Client

func (*Service) GetEcho

func (s *Service) GetEcho() *echo.Echo

func (*Service) Name

func (s *Service) Name() string

func (*Service) Options

func (s *Service) Options() micro.Options

func (*Service) Register

func (s *Service) Register(handler Handler)

func (*Service) Run

func (s *Service) Run() error

func (*Service) Server

func (s *Service) Server() server.Server

func (*Service) String

func (s *Service) String() string

func (*Service) Subscribe

func (s *Service) Subscribe(topic string, h interface{})

type Validatable

type Validatable interface {
	Validate() error
}

type Validator

type Validator struct {
	// contains filtered or unexported fields
}

func NewValidator

func NewValidator() *Validator

func (*Validator) RegisterValidation

func (v *Validator) RegisterValidation(tag string, fn validator.Func, callValidationEvenIfNull ...bool) error

func (*Validator) Validate

func (v *Validator) Validate(i interface{}) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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