middleware

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	McProductProbe = convert(ProductProbeAction)
	McUserProbe    = convert(UserProbeAction)
)
View Source
var (
	MCRecovery = McConvert(NewRecovery())
	MCLogger   = McConvert(NewLoggerMiddleWare())
	MCCors     = McConvert(NewCors())
)

Functions

func GetClientIp

func GetClientIp(r *http.Request) string

func McConvert

func McConvert(handler negroni.Handler) mux.MiddlewareFunc

func NewCors

func NewCors() *cors.Cors

NewCors enable Cross-Origin Resource Sharing detail see: https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Access_control_CORS

func NewMiddleWareFunc

func NewMiddleWareFunc(handler func(*http.Request) (*http.Request, error)) func(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

func ProductProbeAction

func ProductProbeAction(req *http.Request) (*http.Request, error)

func Record

func Record(requestInfo *xreq.RequestInfo)

func UpdateMonitor

func UpdateMonitor(req *http.Request, requestInfo *xreq.RequestInfo)

func UserProbeAction

func UserProbeAction(req *http.Request) (*http.Request, error)

Types

type LoggerMiddleWare

type LoggerMiddleWare struct{}

API access logger

func NewLoggerMiddleWare

func NewLoggerMiddleWare() *LoggerMiddleWare

func (*LoggerMiddleWare) ServeHTTP

func (l *LoggerMiddleWare) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

type ProductProbeParam

type ProductProbeParam struct {
	ProductID   *int64  `uri:"product_id"`
	ProductName *string `uri:"product_name"`
}

type Recovery

type Recovery struct {
	StackAll  bool
	StackSize int
}

func NewRecovery

func NewRecovery() *Recovery

NewRecovery returns a new instance of Recovery

func (*Recovery) ServeHTTP

func (rec *Recovery) ServeHTTP(rw http.ResponseWriter, req *http.Request, next http.HandlerFunc)

type UserProbeParam

type UserProbeParam struct {
	UserID   *int64  `bind:"product_id"`
	UserName *string `bind:"product_name"`
}

Jump to

Keyboard shortcuts

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