Documentation ¶
Overview ¶
Package sohttp 符合goso net对象的 http 服务
Index ¶
- Constants
- func NewRouters(uris []string, httpMethods []string) []so.Router
- type Config
- type Router
- type SoHTTP
- func (soHTTP *SoHTTP) GetPrivateData() interface{}
- func (soHTTP *SoHTTP) Register(handler so.Handler) error
- func (soHTTP *SoHTTP) SetConfig(config *Config) error
- func (soHTTP *SoHTTP) SetConverHandleFunc(ConverHandleFunc func(soHTTP *SoHTTP, handle so.Handler) gin.HandlerFunc) error
- func (soHTTP *SoHTTP) SetErrorNetFunc(errFunc func(code int, err error) interface{}) error
- func (soHTTP *SoHTTP) SetGatePack(gatePack so.GatePack) error
- func (soHTTP *SoHTTP) SetLogger(logger logger.Logger)
- func (soHTTP *SoHTTP) SetPostHandleFunc(...) error
- func (soHTTP *SoHTTP) SetPreHandleFunc(...) error
- func (soHTTP *SoHTTP) Start() error
- func (soHTTP *SoHTTP) Stop() error
Constants ¶
View Source
const (
ContextPrefix = "ctx-"
)
常量
Variables ¶
This section is empty.
Functions ¶
Types ¶
type SoHTTP ¶
type SoHTTP struct { *gin.Engine Config *Config Logger logger.Logger GatePack so.GatePack // gnet 用到 ErrorNetFunc func(code int, err error) interface{} PreHandleFunc func(soHTTP *SoHTTP, c *gin.Context, req interface{}) (context.Context, int, error) PostHandleFunc func(ctx context.Context, soHTTP *SoHTTP, c *gin.Context, resp interface{}) (int, error) ConverHandleFunc func(soHTTP *SoHTTP, handle so.Handler) gin.HandlerFunc // so.HandlerFunc to gin.HandlerFunc }
SoHTTP 符合goso net对象的 http 服务 PreHandleFunc handle 的 前置处理 PostHandleFunc handle 的 后置处理 PreHandleFunc 和 PostHandleFunc 返回的 code 由 ErrorNetFunc 处理 不设置 ErrorNetFunc, code 只能使用 httpcode, 默认使用 BadRequest 和 InternalServerError
func (*SoHTTP) GetPrivateData ¶
func (soHTTP *SoHTTP) GetPrivateData() interface{}
GetPrivateData 获取私有数据
func (*SoHTTP) SetConverHandleFunc ¶
func (soHTTP *SoHTTP) SetConverHandleFunc(ConverHandleFunc func(soHTTP *SoHTTP, handle so.Handler) gin.HandlerFunc) error
SetConverHandleFunc 设置 ConverHandleFunc
func (*SoHTTP) SetErrorNetFunc ¶
SetErrorNetFunc 设置框架层错误处理
func (*SoHTTP) SetGatePack ¶
SetGatePack 设置包对象
func (*SoHTTP) SetPostHandleFunc ¶
func (soHTTP *SoHTTP) SetPostHandleFunc(postHandleFunc func(ctx context.Context, soHTTP *SoHTTP, c *gin.Context, resp interface{}) (int, error)) error
SetPostHandleFunc 设置 请求解码方法
Click to show internal directories.
Click to hide internal directories.