middleware

package
v0.0.0-...-72f410e Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2018 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ReadinessPath = "/readiness"
	LivenessPath  = "/liveness"
)

add Probe for readiness and liveness

View Source
var CPsrFunc = func(spancontext stdot.SpanContext) stdot.StartSpanOption {
	return stdot.ChildOf(spancontext)
}
View Source
var Closelist []Closeble
View Source
var (
	ErrSpanNotFound = errors.New("span was not found in context")
)
View Source
var FPsrFunc = func(spancontext stdot.SpanContext) stdot.StartSpanOption {
	return stdot.FollowsFrom(spancontext)
}
View Source
var Initlist []Register

Functions

func Close

func Close()

func DefaultLimitfactor

func DefaultLimitfactor(c *gin.Context, limit int64) (string, int64)

DefaultLimitfactor default func of GetLimitfactor

func GenerateToken

func GenerateToken(username, password string) (string, error)

func GetSpan

func GetSpan(ctx *gin.Context) (span stdot.Span, exists bool)

GetSpan extracts span from context.

func Init

func Init(conf *setting.Configs) error

func InjectToHeaders

func InjectToHeaders(abortOnErrors bool) gin.HandlerFunc

InjectToHeaders injects span meta-information to request headers.

It may be useful when you want to trace chained request (client->service 1->service 2). In this case you have to save request headers (ctx.Request.Header) and pass it to next level request.

Behaviour on errors determined by abortOnErrors option. If it set to true request handling will be aborted with error.

func JWT

func JWT() gin.HandlerFunc

func Limiter

func Limiter(getLimitfactor GetLimitfactor, limit int64) gin.HandlerFunc

Limiter use getLimitfactor to get fctor and limit then to run

func LivenessProbe

func LivenessProbe() gin.HandlerFunc

func MustGetSpan

func MustGetSpan(ctx *gin.Context) stdot.Span

MustGetSpan extracts span from context. It panics if span was not set.

func NewSpan

func NewSpan(operationName string, opts ...stdot.StartSpanOption) gin.HandlerFunc

NewSpan returns gin.HandlerFunc (middleware) that starts a new span and injects it to request context.

It calls ctx.Next() to measure execution time of all following handlers.

func ReadinessProbe

func ReadinessProbe() gin.HandlerFunc

func SpanFromContext

func SpanFromContext(operationName string, abortOnErrors bool,
	advancedOpts ...stdot.StartSpanOption) gin.HandlerFunc

SpanFromContext returns gin.HandlerFunc (middleware) that extracts parent span from request context and starts a new span as child of parent span.

It calls ctx.Next() to measure execution time of all following handlers.

Behaviour on errors determined by abortOnErrors option. If it set to true request handling will be aborted with error.

func SpanFromHeaders

func SpanFromHeaders(operationName string, psr ParentSpanReferenceFunc,
	abortOnErrors bool, advancedOpts ...stdot.StartSpanOption) gin.HandlerFunc

SpanFromHeaders returns gin.HandlerFunc (middleware) that extracts parent span data from HTTP headers and starts a new span referenced to parent with ParentSpanReferenceFunc.

It calls ctx.Next() to measure execution time of all following handlers.

Behaviour on errors determined by abortOnErrors option. If it set to true request handling will be aborted with error.

func StartPrometheusProbes

func StartPrometheusProbes(engine *gin.Engine)

Types

type Claims

type Claims struct {
	Username string `json:"username"`
	Password string `json:"password"`
	jwt.StandardClaims
}

func ParseToken

func ParseToken(token string) (*Claims, error)

type Closeble

type Closeble func()

func InitTracer

func InitTracer() (err error, close Closeble)

type GetLimitfactor

type GetLimitfactor func(c *gin.Context, limit int64) (string, int64)

GetLimitfactor type define method to get factor used by limit

type ParentSpanReferenceFunc

type ParentSpanReferenceFunc func(stdot.SpanContext) stdot.StartSpanOption

ParentSpanReferenceFunc determines how to reference parent span See opentracing.SpanReferenceType

type Register

type Register func(conf *setting.Configs) (error, Closeble)

Jump to

Keyboard shortcuts

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