Documentation
¶
Index ¶
- Constants
- Variables
- func AddFlag(fs *flag.FlagSet)
- func DefaultServer(conf *config.ServerConfig) *gin.Engine
- func NewServer() *gin.Engine
- func ServerReqMetric() gin.HandlerFunc
- func SetResponse(fc func(ctx context.Context, resp interface{}, err error) (interface{}, int))
- func Shutdown(engine *gin.Engine, ctx context.Context) error
- func Start(engine *gin.Engine)
- type JSON
- type ProtoMessage
- type RateLimiter
Constants ¶
View Source
const ( RespJson = 0 //返回json 默认返回json RespProtobuf = 1 //返回protobuf二进制 )
Variables ¶
View Source
var (
ToResponse func(context.Context, interface{}, error) (interface{}, int)
)
Functions ¶
func DefaultServer ¶
func DefaultServer(conf *config.ServerConfig) *gin.Engine
func ServerReqMetric ¶
func ServerReqMetric() gin.HandlerFunc
func SetResponse ¶
自定义返回
Types ¶
type JSON ¶
type ProtoMessage ¶
type ProtoMessage struct { Code int32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"` Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func TOPROTO ¶
func TOPROTO(buf []byte, err error) (data *ProtoMessage)
func (*ProtoMessage) ProtoMessage ¶
func (*ProtoMessage) ProtoMessage()
func (*ProtoMessage) Reset ¶
func (m *ProtoMessage) Reset()
func (*ProtoMessage) String ¶
func (m *ProtoMessage) String() string
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
RateLimiter bbr middleware.
func NewRateLimiter ¶
func NewRateLimiter(conf *bbr.Config) (s *RateLimiter)
NewRateLimiter return a ratelimit middleware.
func (*RateLimiter) Limit ¶
func (b *RateLimiter) Limit() gin.HandlerFunc
Limit return a bm handler func.
Click to show internal directories.
Click to hide internal directories.