Documentation
¶
Index ¶
- func NewHttpLogger(logger gsr.Logger, traceId string) gsr.Logger
- type HttpDeps
- type HttpServer
- type RegexRouter
- func (rr *RegexRouter) Any(pattern string, handlers ...httpInterfaces.HandlerFunc)
- func (rr *RegexRouter) DELETE(pattern string, handlers ...httpInterfaces.HandlerFunc)
- func (rr *RegexRouter) GET(pattern string, handlers ...httpInterfaces.HandlerFunc)
- func (rr *RegexRouter) HEAD(pattern string, handlers ...httpInterfaces.HandlerFunc)
- func (rr *RegexRouter) OPTIONS(pattern string, handlers ...httpInterfaces.HandlerFunc)
- func (rr *RegexRouter) PATCH(pattern string, handlers ...httpInterfaces.HandlerFunc)
- func (rr *RegexRouter) POST(pattern string, handlers ...httpInterfaces.HandlerFunc)
- func (rr *RegexRouter) PUT(pattern string, handlers ...httpInterfaces.HandlerFunc)
- type Router
- func (r *Router) DELETE(path string, handler httpInterfaces.HandlerFunc)
- func (r *Router) GET(path string, handler httpInterfaces.HandlerFunc)
- func (r *Router) Group(path string) httpInterfaces.RouterInterface
- func (r *Router) HEAD(path string, handler httpInterfaces.HandlerFunc)
- func (r *Router) OPTIONS(path string, handler httpInterfaces.HandlerFunc)
- func (r *Router) PATCH(path string, handler httpInterfaces.HandlerFunc)
- func (r *Router) POST(path string, handler httpInterfaces.HandlerFunc)
- func (r *Router) PUT(path string, handler httpInterfaces.HandlerFunc)
- func (r *Router) RegexGroup(prefix string, middleware ...httpInterfaces.HandlerFunc) httpInterfaces.RegexRouterInterface
- func (r *Router) Use(middleware ...httpInterfaces.HandlerFunc)
- type StaticHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewHttpLogger ¶
NewHttpLogger wraps logger with a pre-populated traceId field for request-scoped logging. When the underlying logger is a *golog.Logger, golog's With() is used to create an efficient child logger; otherwise the original logger is returned unchanged.
Types ¶
type HttpDeps ¶
type HttpDeps struct {
LastHandlerName string
}
func (*HttpDeps) WrapHandler ¶
func (d *HttpDeps) WrapHandler(handler httpInterfaces.HandlerFunc) gin.HandlerFunc
WrapHandler 使用闭包包装处理函数,同时将真实 handler 名称存入 lastHandlerName 供 DebugPrintRouteFunc 使用。 在调用 handler 之前,将请求级 logger(带 traceId)写入上下文。
type HttpServer ¶
type HttpServer struct {
// contains filtered or unexported fields
}
func NewHttpServer ¶
func NewHttpServer() *HttpServer
func (*HttpServer) GetFunctionName ¶
func (receiver *HttpServer) GetFunctionName(i any) string
GetFunctionName 获取函数名
type RegexRouter ¶ added in v1.1.0
type RegexRouter struct {
// contains filtered or unexported fields
}
RegexRouter 收集正则路由并生成 Gin 通配路由的分发 handler
func (*RegexRouter) Any ¶ added in v1.1.0
func (rr *RegexRouter) Any(pattern string, handlers ...httpInterfaces.HandlerFunc)
func (*RegexRouter) DELETE ¶ added in v1.1.0
func (rr *RegexRouter) DELETE(pattern string, handlers ...httpInterfaces.HandlerFunc)
func (*RegexRouter) GET ¶ added in v1.1.0
func (rr *RegexRouter) GET(pattern string, handlers ...httpInterfaces.HandlerFunc)
func (*RegexRouter) HEAD ¶ added in v1.1.0
func (rr *RegexRouter) HEAD(pattern string, handlers ...httpInterfaces.HandlerFunc)
func (*RegexRouter) OPTIONS ¶ added in v1.1.0
func (rr *RegexRouter) OPTIONS(pattern string, handlers ...httpInterfaces.HandlerFunc)
func (*RegexRouter) PATCH ¶ added in v1.1.0
func (rr *RegexRouter) PATCH(pattern string, handlers ...httpInterfaces.HandlerFunc)
func (*RegexRouter) POST ¶ added in v1.1.0
func (rr *RegexRouter) POST(pattern string, handlers ...httpInterfaces.HandlerFunc)
func (*RegexRouter) PUT ¶ added in v1.1.0
func (rr *RegexRouter) PUT(pattern string, handlers ...httpInterfaces.HandlerFunc)
type Router ¶ added in v1.1.0
type Router struct {
// contains filtered or unexported fields
}
func (*Router) DELETE ¶ added in v1.1.0
func (r *Router) DELETE(path string, handler httpInterfaces.HandlerFunc)
func (*Router) GET ¶ added in v1.1.0
func (r *Router) GET(path string, handler httpInterfaces.HandlerFunc)
func (*Router) Group ¶ added in v1.1.0
func (r *Router) Group(path string) httpInterfaces.RouterInterface
func (*Router) HEAD ¶ added in v1.1.0
func (r *Router) HEAD(path string, handler httpInterfaces.HandlerFunc)
func (*Router) OPTIONS ¶ added in v1.1.0
func (r *Router) OPTIONS(path string, handler httpInterfaces.HandlerFunc)
func (*Router) PATCH ¶ added in v1.1.0
func (r *Router) PATCH(path string, handler httpInterfaces.HandlerFunc)
func (*Router) POST ¶ added in v1.1.0
func (r *Router) POST(path string, handler httpInterfaces.HandlerFunc)
func (*Router) PUT ¶ added in v1.1.0
func (r *Router) PUT(path string, handler httpInterfaces.HandlerFunc)
func (*Router) RegexGroup ¶ added in v1.1.0
func (r *Router) RegexGroup(prefix string, middleware ...httpInterfaces.HandlerFunc) httpInterfaces.RegexRouterInterface
func (*Router) Use ¶ added in v1.1.0
func (r *Router) Use(middleware ...httpInterfaces.HandlerFunc)
type StaticHandler ¶
type StaticHandler struct {
// contains filtered or unexported fields
}
func NewStaticHandler ¶
func NewStaticHandler(engine *gin.Engine) *StaticHandler
Source Files
¶
- http_deps.go
- http_logger.go
- http_server.go
- regex_dispatch.go
- router.go
- router_context.go
- static_handler.go
Click to show internal directories.
Click to hide internal directories.