Documentation ¶
Index ¶
- func AccessLogMiddleware(opt *AccessLogMwOptions) gin.HandlerFunc
- func GetConfigPath() string
- func OutermostRecover() gin.HandlerFunc
- func SemicolonMiddleware() gin.HandlerFunc
- func ServerRecover() gin.HandlerFunc
- func SetConfigPath(path string)
- func TrafficStopMiddleware() gin.HandlerFunc
- type AccessLogMwOptions
- type Method
- type MiddlewaresOptions
- type Options
- type PprofOptions
- type Server
- func (s *Server) AddRoute(method Method, path string, handlers ...gin.HandlerFunc) *Server
- func (s *Server) AddRouteWithMethods(methods []Method, path string, handlers ...gin.HandlerFunc) *Server
- func (s *Server) GoAttach(f func())
- func (s *Server) Start()
- func (s *Server) Stop(ctx context.Context) error
- func (s *Server) StoppingNotify() <-chan struct{}
- type ServiceOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AccessLogMiddleware ¶
func AccessLogMiddleware(opt *AccessLogMwOptions) gin.HandlerFunc
func GetConfigPath ¶
func GetConfigPath() string
func OutermostRecover ¶
func OutermostRecover() gin.HandlerFunc
func SemicolonMiddleware ¶
func SemicolonMiddleware() gin.HandlerFunc
func ServerRecover ¶
func ServerRecover() gin.HandlerFunc
func SetConfigPath ¶
func SetConfigPath(path string)
func TrafficStopMiddleware ¶
func TrafficStopMiddleware() gin.HandlerFunc
Types ¶
type AccessLogMwOptions ¶
type AccessLogMwOptions struct { Enabled bool Pattern string Path string FilePathPattern string // 定义文件路径名称格式 NoFile bool MaxAge time.Duration // 默认7天 RotationTime time.Duration // 默认1天 RotationSize int64 // 单位MB,默认1024 }
func NewDefaultAccessLogOptions ¶
func NewDefaultAccessLogOptions() *AccessLogMwOptions
type Method ¶
type Method string
const ( GET Method = http.MethodGet HEAD Method = http.MethodHead POST Method = http.MethodPost PUT Method = http.MethodPut PATCH Method = http.MethodPatch DELETE Method = http.MethodDelete CONNECT Method = http.MethodConnect OPTIONS Method = http.MethodOptions TRACE Method = http.MethodTrace )
type MiddlewaresOptions ¶
type MiddlewaresOptions struct {
AccessLog *AccessLogMwOptions
}
type Options ¶
type Options struct { Port int Mode string ShutdownTimeout time.Duration Middlewares *MiddlewaresOptions }
func NewDefaultOptions ¶
func NewDefaultOptions() *Options
type PprofOptions ¶
PprofOptions 用于开启调试模式
type Server ¶
type Server struct { *http.Server *gin.Engine PreStart func() error PreStop func(context.Context) error // contains filtered or unexported fields }
func (*Server) AddRouteWithMethods ¶
func (*Server) GoAttach ¶
func (s *Server) GoAttach(f func())
GoAttach 用指定func创建一个goroutine,并用waitgroup跟踪它 注意传递的函数必须在s.StoppingNotify()关闭后停止
func (*Server) StoppingNotify ¶
func (s *Server) StoppingNotify() <-chan struct{}
StoppingNotify 返回一个channel,它会在server停止时被关闭
type ServiceOptions ¶
ServiceOptions 整合了服务的全局配置
Source Files ¶
Click to show internal directories.
Click to hide internal directories.