contextpkg

package
v0.2.16 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: Apache-2.0 Imports: 10 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientIP

func ClientIP(ctx context.Context) string

ClientIP 获取客户端IP

func ClientIPFromGRPC

func ClientIPFromGRPC(ctx context.Context) (clientIP string)

ClientIPFromGRPC ...

func ClientIPFromHTTP

func ClientIPFromHTTP(ctx context.Context, r *http.Request) (clientIP string)

ClientIPFromHTTP ...

func FromClientContext

func FromClientContext(ctx context.Context) (tr transport.Transporter, ok bool)

FromClientContext 等于 transport.FromClientContext

func FromServerContext

func FromServerContext(ctx context.Context) (tr transport.Transporter, ok bool)

FromServerContext 等于 transport.FromServerContext

func GetClientIpFromContext

func GetClientIpFromContext(ctx context.Context) (clientIp string, ok bool)

GetClientIpFromContext extract client ip from context

func MatchGRPCClientContext

func MatchGRPCClientContext(ctx context.Context) (tr *grpc.Transport, ok bool)

MatchGRPCClientContext ...

func MatchGRPCServerContext

func MatchGRPCServerContext(ctx context.Context) (tr *grpc.Transport, ok bool)

MatchGRPCServerContext ...

func MatchHTTPClientContext

func MatchHTTPClientContext(ctx context.Context) (tr http.Transporter, ok bool)

MatchHTTPClientContext ...

func MatchHTTPContext

func MatchHTTPContext(ctx context.Context) (http.Context, bool)

MatchHTTPContext 匹配 Deprecated: 不建议使用此方法 建议使用: contextpkg.MatchHTTPServerContext or contextpkg.MatchGRPCServerContext

func MatchHTTPServerContext

func MatchHTTPServerContext(ctx context.Context) (tr http.Transporter, ok bool)

MatchHTTPServerContext ...

func SetClientIpToContext

func SetClientIpToContext(ctx context.Context, clientIp string) context.Context

SetClientIpToContext put client ip into context

func SetTrustedPlatform

func SetTrustedPlatform(platformHeader string)

SetTrustedPlatform 设置信任的平台

func ToGRPCTransporter

func ToGRPCTransporter(kratosTr transport.Transporter) (grpcTr *grpc.Transport, ok bool)

ToGRPCTransporter ...

func ToHTTPTransporter

func ToHTTPTransporter(kratosTr transport.Transporter) (httpTr http.Transporter, ok bool)

ToHTTPTransporter ...

Types

This section is empty.

Jump to

Keyboard shortcuts

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