gin

package
v0.0.0-...-7429660 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DebugMode indicates gin mode is debug.
	DebugMode = "debug"
	// ReleaseMode indicates gin mode is release.
	ReleaseMode = "release"
	// TestMode indicates gin mode is test.
	TestMode = "test"
)
View Source
const EnvGinMode = "GIN_MODE"

EnvGinMode gin模式的环境变量参数名称

Variables

View Source
var DefaultErrorWriter io.Writer = os.Stderr

DefaultErrorWriter is the default io.Writer used by Gin to debug errors

View Source
var DefaultWriter io.Writer = os.Stdout

DefaultWriter is the default io.Writer used by Gin for debug output and middleware output like Logger() or Recovery(). Note that both Logger and Recovery provides custom ways to configure their output io.Writer. To support coloring in Windows use:

import "github.com/mattn/go-colorable"
gin.DefaultWriter = colorable.NewColorableStdout()

Functions

func IsDebugging

func IsDebugging() bool

IsDebugging returns true if the framework is running in debug mode. Use SetMode(gin.ReleaseMode) to disable debug mode.

func SetMode

func SetMode(value string)

SetMode sets gin mode according to input string.

Types

type Context

type Context struct {
	// http请求
	Request *http.Request
}

type Engine

type Engine struct {
	// 路由组
	RouterGroup

	// UseH2C enable h2c support.
	UseH2C bool
	// contains filtered or unexported fields
}

func (*Engine) Handler

func (engine *Engine) Handler() http.Handler

func (*Engine) Run

func (engine *Engine) Run(addr ...string) (err error)

Run 启动Http监听服务,该方法会阻塞调用协程

func (*Engine) ServeHTTP

func (engine *Engine) ServeHTTP(w http.ResponseWriter, req *http.Request)

type HandlerFunc

type HandlerFunc func(ctx *Context)

HandlerFunc 路由及中间件处理程序

type HandlersChain

type HandlersChain []HandlerFunc

HandlersChain 处理程序链

type RouterGroup

type RouterGroup struct {
}

RouterGroup 路由组,包含路由极其处理程序数组

Jump to

Keyboard shortcuts

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