rpcmetadata

package
v0.0.0-...-60b8695 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package rpcmetadata contains utilities for transporting common request metadata over gRPC.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithForwardedAuth

func WithForwardedAuth(ctx context.Context, allowInsecure bool) (grpc.CallOption, error)

WithForwardedAuth returns a grpc.CallOption with authentication from the incoming context ctx.

func WithForwardedRequestID

func WithForwardedRequestID(ctx context.Context) context.Context

WithForwardedRequestID forwards the incoming request ID to outgoing RPCs.

Types

type MD

type MD struct {
	ID             string
	AuthType       string
	AuthValue      string
	ServiceType    string
	ServiceVersion string
	NetAddress     string
	AllowInsecure  bool

	// Host is the hostname the request is directed to.
	Host string

	// URI is the URI the request is directed to.
	URI string

	// XForwardedFor is set from the X-Forwarded-For header.
	XForwardedFor string

	// UserAgent is set from the User-Agent or the grpcgateway-user-agent header.
	UserAgent string
}

MD contains The Things Stack metadata fields

func FromIncomingContext

func FromIncomingContext(ctx context.Context) (m MD)

FromIncomingContext returns The Things Stack metadata from the incoming context ctx.

func FromMetadata

func FromMetadata(md metadata.MD) (m MD)

FromMetadata returns The Things Stack metadata from metadata.MD

func FromOutgoingContext

func FromOutgoingContext(ctx context.Context) (m MD)

FromOutgoingContext returns The Things Stack metadata from the outgoing context ctx.

func (MD) GetRequestMetadata

func (m MD) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error)

GetRequestMetadata returns the request metadata with per-rpc credentials

func (MD) RequireTransportSecurity

func (m MD) RequireTransportSecurity() bool

RequireTransportSecurity returns true if authentication is configured

func (MD) ToIncomingContext

func (m MD) ToIncomingContext(ctx context.Context) context.Context

ToIncomingContext puts The Things Stack metadata fields in an incoming context.Context

func (MD) ToMetadata

func (m MD) ToMetadata() metadata.MD

ToMetadata puts The Things Stack metadata fields in a metadata.MD

func (MD) ToOutgoingContext

func (m MD) ToOutgoingContext(ctx context.Context) context.Context

ToOutgoingContext puts The Things Stack metadata fields in an outgoing context.Context

Jump to

Keyboard shortcuts

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