rkgfctx

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package rkgfctx defines utility functions and variables used by GoFrame middleware

Index

Constants

View Source
const (
	// RequestIdKey is the header key sent to client
	RequestIdKey = "X-Request-Id"
	// TraceIdKey is the header sent to client
	TraceIdKey = "X-Trace-Id"
)

Variables

This section is empty.

Functions

func AddHeaderToClient

func AddHeaderToClient(ctx *ghttp.Request, key, value string)

AddHeaderToClient headers that would be sent to client. Values would be merged.

func EndTraceSpan

func EndTraceSpan(ctx *ghttp.Request, span trace.Span, success bool)

EndTraceSpan end span

func GetCsrfToken added in v0.0.2

func GetCsrfToken(ctx *ghttp.Request) string

GetCsrfToken return csrf token if exists

func GetEntryName

func GetEntryName(ctx *ghttp.Request) string

GetEntryName extract entry name from context.

func GetEvent

func GetEvent(ctx *ghttp.Request) rkquery.Event

GetEvent extract takes the call-scoped EventData from middleware.

func GetIncomingHeaders

func GetIncomingHeaders(ctx *ghttp.Request) http.Header

GetIncomingHeaders extract call-scoped incoming headers

func GetJwtToken added in v0.0.2

func GetJwtToken(ctx *ghttp.Request) *jwt.Token

GetJwtToken return jwt.Token if exists

func GetLogger

func GetLogger(ctx *ghttp.Request) *zap.Logger

GetLogger extract takes the call-scoped zap logger from middleware.

func GetRequestId

func GetRequestId(ctx *ghttp.Request) string

GetRequestId extract request id from context. If user enabled meta interceptor, then a random request Id would e assigned and set to context as value. If user called AddHeaderToClient() with key of RequestIdKey, then a new request id would be updated.

func GetTraceId

func GetTraceId(ctx *ghttp.Request) string

GetTraceId extract trace id from context.

func GetTraceSpan

func GetTraceSpan(ctx *ghttp.Request) trace.Span

GetTraceSpan extract the call-scoped span from context.

func GetTracer

func GetTracer(ctx *ghttp.Request) trace.Tracer

GetTracer extract the call-scoped tracer from context.

func GetTracerPropagator

func GetTracerPropagator(ctx *ghttp.Request) propagation.TextMapPropagator

GetTracerPropagator extract takes the call-scoped propagator from middleware.

func GetTracerProvider

func GetTracerProvider(ctx *ghttp.Request) trace.TracerProvider

GetTracerProvider extract the call-scoped tracer provider from context.

func InjectSpanToHttpRequest

func InjectSpanToHttpRequest(ctx *ghttp.Request, req *http.Request)

InjectSpanToHttpRequest inject span to http request

func NewTraceSpan

func NewTraceSpan(ctx *ghttp.Request, name string) trace.Span

NewTraceSpan start a new span

func SetHeaderToClient

func SetHeaderToClient(ctx *ghttp.Request, key, value string)

SetHeaderToClient headers that would be sent to client. Values would be overridden.

Types

This section is empty.

Jump to

Keyboard shortcuts

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