web

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const TraceIdHeader = "X-Trace-Id"

Variables

View Source
var Wrapper = Wrap

Wrapper make sure we are backward compatible

Functions

func AddTraceId added in v0.1.0

func AddTraceId() gin.HandlerFunc

AddTraceId 为每个请求生成/透传 traceId,并写回响应头方便排查问题

func BlockHandler

func BlockHandler() gin.HandlerFunc

BlockHandler will pass the call from /debug/pprof/block to pprof

func CmdlineHandler

func CmdlineHandler() gin.HandlerFunc

CmdlineHandler will pass the call from /debug/pprof/cmdline to pprof

func Cors added in v0.3.0

func Cors() gin.HandlerFunc

Cors 跨域中间件,放行 OPTIONS 预检请求 使用:app.Web.Router.Use(web.Cors())

func GoroutineHandler

func GoroutineHandler() gin.HandlerFunc

GoroutineHandler will pass the call from /debug/pprof/goroutine to pprof

func HeapHandler

func HeapHandler() gin.HandlerFunc

HeapHandler will pass the call from /debug/pprof/heap to pprof

func IndexHandler

func IndexHandler() gin.HandlerFunc

IndexHandler will pass the call from /debug/pprof to pprof

func MutexHandler

func MutexHandler() gin.HandlerFunc

MutexHandler will pass the call from /debug/pprof/mutex to pprof

func ProfileHandler

func ProfileHandler() gin.HandlerFunc

ProfileHandler will pass the call from /debug/pprof/profile to pprof

func SymbolHandler

func SymbolHandler() gin.HandlerFunc

SymbolHandler will pass the call from /debug/pprof/symbol to pprof

func ThreadCreateHandler

func ThreadCreateHandler() gin.HandlerFunc

ThreadCreateHandler will pass the call from /debug/pprof/threadcreate to pprof

func TraceHandler

func TraceHandler() gin.HandlerFunc

TraceHandler will pass the call from /debug/pprof/trace to pprof

func Wrap

func Wrap(router *gin.Engine)

Wrap adds several routes from package `net/http/pprof` to *gin.Engine object

func WrapGroup

func WrapGroup(router *gin.RouterGroup)

WrapGroup adds several routes from package `net/http/pprof` to *gin.RouterGroup object

Types

type Web

type Web struct {
	Router *gin.Engine
	// contains filtered or unexported fields
}

Web

func NewWeb

func NewWeb(conf *config.Config) (*Web, error)

NewWeb

func (*Web) Run

func (s *Web) Run() error

Run 启动 HTTP 服务(阻塞) 正常优雅关闭时返回 nil;启动失败(如端口被占用)返回错误

func (*Web) Shutdown added in v0.2.0

func (s *Web) Shutdown(ctx context.Context) error

Shutdown 优雅关闭Web服务器

Jump to

Keyboard shortcuts

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