impl

package
v1.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 14, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHttpLogger

func NewHttpLogger(logger gsr.Logger, traceId string) gsr.Logger

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 NewHttpDeps

func NewHttpDeps() *HttpDeps

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 获取函数名

func (*HttpServer) RunHttp

func (receiver *HttpServer) RunHttp()

RunHttp 启动HTTP服务器并注册路由和中间件

func (*HttpServer) Stop

func (receiver *HttpServer) Stop() error

Stop 优雅停止HTTP服务器

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 NewRouter added in v1.1.0

func NewRouter(group gin.IRouter, deps *HttpDeps) *Router

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 (*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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址