courier

package
v0.0.0-...-61829c1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2019 License: Apache-2.0 Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var VersionSwitchKey = "X-Version"

Functions

func GetContextValue

func GetContextValue(ctx context.Context, contextProvider IContextProvider) interface{}

func ModifyRequestIDWithVersionSwitch

func ModifyRequestIDWithVersionSwitch(requestID string, version string) string

func ParseVersionSwitch

func ParseVersionSwitch(s string) (string, string, bool)

func Run

func Run(router *Router, serves ...IServe)

func UnmarshalBytes

func UnmarshalBytes(data []byte, v interface{}) error

Types

type EmptyOperator

type EmptyOperator struct {
}

func (EmptyOperator) NoOutput

func (g EmptyOperator) NoOutput() bool

func (EmptyOperator) Output

func (g EmptyOperator) Output(ctx context.Context) (result interface{}, err error)

type IContextProvider

type IContextProvider interface {
	IOperator
	ContextKey() string
}

type IDefaultsMarshal

type IDefaultsMarshal interface {
	MarshalDefaults(v interface{})
}

type IEmptyOperator

type IEmptyOperator interface {
	IOperator
	NoOutput() bool
}

type IMeta

type IMeta interface {
	Meta() Metadata
}

type IOperator

type IOperator interface {
	Output(ctx context.Context) (result interface{}, err error)
}

func NewOperatorBy

func NewOperatorBy(opType reflect.Type, defaultOp IOperator, decodeOperator OperatorDecoder) (op IOperator, err error)

type IServe

type IServe interface {
	Serve(router *Router) error
}

type Metadata

type Metadata map[string][]string

func MetadataMerge

func MetadataMerge(metas ...Metadata) Metadata

func MetadataWithVersionSwitch

func MetadataWithVersionSwitch(xVersion string) Metadata

func (Metadata) Add

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

func (Metadata) Get

func (m Metadata) Get(key string) string

func (Metadata) Has

func (m Metadata) Has(key string) bool

func (Metadata) Merge

func (m Metadata) Merge(metadata Metadata)

func (Metadata) Set

func (m Metadata) Set(key string, values ...string)

type OperatorDecoder

type OperatorDecoder func(op IOperator, rv reflect.Value) error

type OperatorMeta

type OperatorMeta struct {
	IsLast     bool
	ContextKey string
	Operator   IOperator
	Type       reflect.Type
}

func GetOperatorMeta

func GetOperatorMeta(op IOperator, last bool) OperatorMeta

func ToOperatorMetaList

func ToOperatorMetaList(ops ...IOperator) (opMetas []OperatorMeta)

type Result

type Result struct {
	Err       error
	Meta      Metadata
	Data      []byte
	Unmarshal TUnmarshal
}

func (Result) BindMeta

func (r Result) BindMeta(meta Metadata) *Result

func (Result) Into

func (r Result) Into(v interface{}) error

type Route

type Route struct {
	Operators []IOperator
	// contains filtered or unexported fields
}

func (*Route) EffectiveOperators

func (route *Route) EffectiveOperators() (operators []IOperator, operatorTypeNames []string)

type Router

type Router struct {
	// contains filtered or unexported fields
}

func NewRouter

func NewRouter(operators ...IOperator) *Router

func (*Router) Register

func (router *Router) Register(r *Router)

func (*Router) Route

func (router *Router) Route() *Route

func (*Router) Routes

func (router *Router) Routes() (routes []*Route)

type TUnmarshal

type TUnmarshal func(data []byte, v interface{}) error

type WithVersionSwitch

type WithVersionSwitch struct {
	XVersion string `name:"X-Version,omitempty" in:"header"`
}

Jump to

Keyboard shortcuts

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