transport

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewServerContext

func NewServerContext(ctx context.Context, tr Transporter) context.Context

NewServerContext returns a new Context that carries value.

Types

type Header map[string][]string

Header is request header http: http.Request.Header gRPC: metadata.MD

func (Header) Add

func (h Header) Add(key string, vals ...string)

func (Header) Copy

func (h Header) Copy() Header

func (Header) Get

func (h Header) Get(key string) string

func (Header) Keys

func (h Header) Keys() []string

func (Header) Len

func (h Header) Len() int

func (Header) Set

func (h Header) Set(key string, vals ...string)

func (Header) Values

func (h Header) Values(key string) []string

type Kind

type Kind string

Kind is transport kind

const (
	KindHTTP Kind = "HTTP"
	KindGRPC Kind = "GRPC"
)

type TransportKey

type TransportKey struct{}

type Transporter

type Transporter interface {
	// Transporter Kind
	// http: KindHTTP
	// gRPC: KindGRPC
	Kind() Kind

	// RequestHeader returns Transporter request header
	// http: http.Request.Header
	// gRPC: metadata.MD
	RequestHeader() Header

	// ResponseHeader returns Transporter response header
	// http: http.ResponseWriter.Header
	// gRPC: metadata.MD
	ResponseHeader() Header

	// SetHeader set response header
	SetHeader(key, value string)

	// AddHeader add value to response header
	AddHeader(key, value string)
}

func FromServerContext

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

FromServerContext returns the Transport value stored in ctx, if any.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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