core

package
v0.0.0-...-988857b Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HttpHeaderKeyTraceID = "ipalfish-trace-id"

	WildCharacter = ":"

	RoutePath = "req-simple-path"

	HttpHeaderKeyGroup = "ipalfish-group"
	HttpHeaderKeyHead  = "ipalfish-head"

	CookieNameGroup = "ipalfish_group"
	DefaultGroup    = ""

	ContextKeyHead = "Head"
)
View Source
const ErrCodeKey = "ErrCode"

Variables

This section is empty.

Functions

func ContextSetErrCode

func ContextSetErrCode(ctx context.Context, errCode int)

func InjectFromRequest

func InjectFromRequest() gin.HandlerFunc

func Metric

func Metric() gin.HandlerFunc

Metric returns a metric middleware

func Recovery

func Recovery() gin.HandlerFunc

Recovery returns a middleware that recovers from any panics and writes a 500 if there was one.

func Trace

func Trace() gin.HandlerFunc

Trace returns a trace middleware

Types

type Context

type Context struct {
	*gin.Context
}

Context warp gin Context

func (*Context) Bind

func (c *Context) Bind(obj interface{}) error

Bind checks the Content-Type to select a binding engine automatically

type ErrCode

type ErrCode struct {
	// contains filtered or unexported fields
}

type HandlerFunc

type HandlerFunc func(*Context)

HandlerFunc ...

type Head struct {
	Uid        int64             `thrift:"uid,1" json:"uid"`
	Source     int32             `thrift:"source,2" json:"source"`
	Ip         string            `thrift:"ip,3" json:"ip"`
	Region     string            `thrift:"region,4" json:"region"`
	Dt         int32             `thrift:"dt,5" json:"dt"`
	Unionid    string            `thrift:"unionid,6" json:"unionid"`
	Did        string            `thrift:"did,7" json:"did"`
	Zone       int32             `thrift:"zone,8" json:"zone"`
	ZoneName   string            `thrift:"zone_name,9" json:"zone_name"`
	Properties map[string]string `thrift:"properties,10" json:"properties"`
}

type HttpServer

type HttpServer struct {
	*gin.Engine
}

HttpServer is the http server, Create an instance of GinServer, by using NewGinServer()

func NewHttpServer

func NewHttpServer() *HttpServer

NewHttpServer create http server with gin

func (*HttpServer) Any

func (s *HttpServer) Any(relativePath string, handlers ...HandlerFunc)

Any registers a route that matches all the HTTP methods.

func (*HttpServer) DELETE

func (s *HttpServer) DELETE(relativePath string, handlers ...HandlerFunc)

DELETE is a shortcut for router.Handle("DELETE", path, handle).

func (*HttpServer) GET

func (s *HttpServer) GET(relativePath string, handlers ...HandlerFunc)

GET is a shortcut for router.Handle("GET", path, handle).

func (*HttpServer) HEAD

func (s *HttpServer) HEAD(relativePath string, handlers ...HandlerFunc)

HEAD is a shortcut for router.Handle("HEAD", path, handle).

func (*HttpServer) OPTIONS

func (s *HttpServer) OPTIONS(relativePath string, handlers ...HandlerFunc)

OPTIONS is a shortcut for router.Handle("OPTIONS", path, handle).

func (*HttpServer) PATCH

func (s *HttpServer) PATCH(relativePath string, handlers ...HandlerFunc)

PATCH is a shortcut for router.Handle("PATCH", path, handle).

func (*HttpServer) POST

func (s *HttpServer) POST(relativePath string, handlers ...HandlerFunc)

POST is a shortcut for router.Handle("POST", path, handle).

func (*HttpServer) PUT

func (s *HttpServer) PUT(relativePath string, handlers ...HandlerFunc)

PUT is a shortcut for router.Handle("PUT", path, handle).

func (*HttpServer) Use

func (s *HttpServer) Use(middleware ...HandlerFunc)

Use attachs a global middleware to the router

Jump to

Keyboard shortcuts

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