grpc

package
v1.0.1000 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2023 License: MIT Imports: 7 Imported by: 7

Documentation

Index

Constants

View Source
const GrpcContentType = "application/grpc"
View Source
const GrpcWebContentType = "application/grpc-web"
View Source
const GrpcWebTextContentType = "application/grpc-web-text"

Variables

This section is empty.

Functions

func GetBearerTokenFromContext

func GetBearerTokenFromContext(ctx context.Context) (token string)

func GetIPAddressFromContext

func GetIPAddressFromContext(ctx context.Context) (ip string, err error)

func GetUUIDFromContext

func GetUUIDFromContext(ctx context.Context) string

func IsGrpcNativeRequest

func IsGrpcNativeRequest(req *http.Request) bool

func IsGrpcRequest

func IsGrpcRequest(req *http.Request) bool

func IsGrpcRequestReflection

func IsGrpcRequestReflection(req *http.Request) bool

func IsGrpcWebRequest

func IsGrpcWebRequest(req *http.Request) bool

func NewContextFromRequest

func NewContextFromRequest(r *http.Request) context.Context

Types

type ErrorObjectMsg

type ErrorObjectMsg struct {
	Code    string
	Message string
}

type NiceMD

type NiceMD metadata.MD

NiceMD is a convenience wrapper definiting extra functions on the metadata.

func ExtractIncoming

func ExtractIncoming(ctx context.Context) NiceMD

ExtractIncoming extracts an inbound metadata from the server-side context.

This function always returns a NiceMD wrapper of the metadata.MD, in case the context doesn't have metadata it returns a new empty NiceMD.

func ExtractOutgoing

func ExtractOutgoing(ctx context.Context) NiceMD

ExtractOutgoing extracts an outbound metadata from the client-side context.

This function always returns a NiceMD wrapper of the metadata.MD, in case the context doesn't have metadata it returns a new empty NiceMD.

func (NiceMD) Add

func (m NiceMD) Add(key string, value string) NiceMD

Add retrieves a single value from the metadata.

It works analogously to http.Header.Add, as it appends to any existing values associated with key.

The function is binary-key safe.

func (NiceMD) Clone

func (m NiceMD) Clone(copiedKeys ...string) NiceMD

Clone performs a *deep* copy of the metadata.MD.

You can specify the lower-case copiedKeys to only copy certain whitelisted keys. If no keys are explicitly whitelisted all keys get copied.

func (NiceMD) Del

func (m NiceMD) Del(key string) NiceMD

Del retrieves a single value from the metadata.

It works analogously to http.Header.Del, deleting all values if they exist.

The function is binary-key safe.

func (NiceMD) Get

func (m NiceMD) Get(key string) string

Get retrieves a single value from the metadata.

It works analogously to http.Header.Get, returning the first value if there are many set. If the value is not set, an empty string is returned.

The function is binary-key safe.

func (NiceMD) GetAll

func (m NiceMD) GetAll() (res map[string]string)

func (NiceMD) Set

func (m NiceMD) Set(key string, value string) NiceMD

Set sets the given value in a metadata.

It works analogously to http.Header.Set, overwriting all previous metadata values.

The function is binary-key safe.

func (NiceMD) ToHttpHeader

func (m NiceMD) ToHttpHeader() (req http.Header)

func (NiceMD) ToIncoming

func (m NiceMD) ToIncoming(ctx context.Context) context.Context

ToIncoming sets the given NiceMD as a server-side context for dispatching.

This is mostly useful in ServerInterceptors..

func (NiceMD) ToJSON

func (m NiceMD) ToJSON() []byte

func (NiceMD) ToJSONString

func (m NiceMD) ToJSONString() string

func (NiceMD) ToOutgoing

func (m NiceMD) ToOutgoing(ctx context.Context) context.Context

ToOutgoing sets the given NiceMD as a client-side context for dispatching.

type Status

type Status struct {
	Grpc *status.Status
}

func StatusFromGrpcServices

func StatusFromGrpcServices(err error) (s *Status)

func (*Status) ErrorObject

func (c *Status) ErrorObject() error

Jump to

Keyboard shortcuts

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