Documentation ¶
Overview ¶
Package sohttp 符合goso net对象的 http 服务
Index ¶
- func NewRouters(uris []string, httpMethods []string) []so.Router
- type Config
- type Router
- type SoHTTP
- func (soHTTP *SoHTTP) Register(handler so.Handler) error
- func (soHTTP *SoHTTP) SetBeforeHandleFunc(...) error
- func (soHTTP *SoHTTP) SetBehindHandleFunc(...) 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) Start() error
- func (soHTTP *SoHTTP) Stop() error
Constants ¶
This section is empty.
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{} BeforeHandleFunc func(soHTTP *SoHTTP, c *gin.Context, req interface{}) (context.Context, int, error) BehindHandleFunc 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 服务 BeforeHandleFunc handle 的 前置处理 BehindHandleFunc handle 的 后置处理 BeforeHandleFunc 和 BehindHandleFunc 返回的 code 由 ErrorNetFunc 处理 不设置 ErrorNetFunc, code 只能使用 httpcode, 默认使用 BadRequest 和 InternalServerError
func (*SoHTTP) SetBeforeHandleFunc ¶ added in v0.0.5
func (soHTTP *SoHTTP) SetBeforeHandleFunc(beforeHandleFunc func(soHTTP *SoHTTP, c *gin.Context, req interface{}) (context.Context, int, error)) error
SetBeforeHandleFunc 设置 响应编码方法
func (*SoHTTP) SetBehindHandleFunc ¶ added in v0.0.5
func (soHTTP *SoHTTP) SetBehindHandleFunc(behindHandleFunc func(ctx context.Context, soHTTP *SoHTTP, c *gin.Context, resp interface{}) (int, error)) error
SetBehindHandleFunc 设置 请求解码方法
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 设置包对象
Click to show internal directories.
Click to hide internal directories.