gin

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LegoRequestID       = "lego-request-id"
	LegoRequestMethod   = "lego-request-method"
	LegoRequestPath     = "lego-request-path"
	LegoRequestRawQuery = "lego-request-rawquery"

	LegoHandlerErr = "lego-handler-err"
	LegoHandlerMsg = "lego-handler-msg"

	HandleCrash       = "handle crash"
	HandleError       = "handle error"
	BeforeHandleError = "before handle error"
	BehindHandleError = "behind handle error"
)

常量

Variables

This section is empty.

Functions

func ContextLoad

func ContextLoad(data *ContextData) context.Context

ContextLoad 导入

func ContextWithMethod

func ContextWithMethod(ctx context.Context, method string) context.Context

ContextWithMethod returns a new Context that carries value u.

func ContextWithPath

func ContextWithPath(ctx context.Context, path string) context.Context

ContextWithPath returns a new Context that carries value u.

func ContextWithRawQuery

func ContextWithRawQuery(ctx context.Context, rawQuery string) context.Context

ContextWithRawQuery returns a new Context that carries value u.

func ContextWithRequestID

func ContextWithRequestID(ctx context.Context, requestID string) context.Context

ContextWithRequestID returns a new Context that carries value u.

func ContextWithValue

func ContextWithValue(value *ContextValue) context.Context

ContextWithValue returns a new Context that carries value u.

func Register

func Register(engine *gin.Engine, beforeHandle, behindHandle func(ctx context.Context, c *gin.Context, v interface{}) error, handlers ...legocore.Handler)

Register 注册处理器

Types

type ContextData

type ContextData struct {
	Value    *ContextValue `json:"value,omitempty"`
	Deadline int64         `json:"deadline,omitempty"`
}

ContextData 传输用

func ContextDump

func ContextDump(ctx context.Context) *ContextData

ContextDump 导出

type ContextValue

type ContextValue struct {
	RequestID string `json:"request_id,omitempty"` // 服务端ID
	Method    string `json:"method,omitempty"`
	Path      string `json:"path,omitempty"`
	RawQuery  string `json:"raw_query,omitempty"`
}

ContextValue 上下文结构体

func ContextFetchValue

func ContextFetchValue(ctx context.Context) (*ContextValue, bool)

ContextFetchValue returns the User value stored in ctx, if any.

func (*ContextValue) String

func (v *ContextValue) String() string

String 添加 stringer 方法

Jump to

Keyboard shortcuts

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