context

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeJson   = "application/json"
	TypePlain  = "text/plain"
	TypeProto  = "application/protobuf"
	TypeXProto = "application/x-protobuf"
)

Variables

This section is empty.

Functions

func LoggerFromContext

func LoggerFromContext(c context.Context) log.Logger

func MtoHeader

func MtoHeader(m M) http.Header

func ServiceNameFromContext

func ServiceNameFromContext(c context.Context) string

func WithLogger

func WithLogger(c context.Context, log log.Logger) context.Context

func WithServiceName

func WithServiceName(c context.Context, name string) context.Context

Types

type C

type C interface {
	Publish(*R)
	Request() *R
	Ack(args ...interface{})
	Nack(args ...interface{})
}

type Context

type Context struct {
	C     C
	Error error
	// Log      log.Logger
	TraceID     string
	SpanID      string
	ServiceName string
	Request     *R
	Headers     M
	// contains filtered or unexported fields
}

func NewAndRun

func NewAndRun(c C, handlers ...Handler) *Context

func NewContext

func NewContext(c C) *Context

func (*Context) Abort

func (c *Context) Abort(v interface{})

func (*Context) AbortWithError

func (c *Context) AbortWithError(v interface{}, err error)

func (*Context) Ack

func (c *Context) Ack(args ...interface{})

func (*Context) Bind

func (c *Context) Bind(v interface{}) error

func (*Context) Deadline

func (c *Context) Deadline() (time.Time, bool)

func (*Context) Done

func (c *Context) Done() <-chan struct{}

func (*Context) Err

func (c *Context) Err() error

func (*Context) Get

func (c *Context) Get(key interface{}) interface{}

func (*Context) JSON

func (c *Context) JSON(v interface{})

func (*Context) Log

func (c *Context) Log() log.Logger

func (*Context) Nack

func (c *Context) Nack(args ...interface{})

func (*Context) Next

func (c *Context) Next()

func (*Context) Proto

func (c *Context) Proto(pb proto.Message)

func (*Context) RunHandlers

func (c *Context) RunHandlers(handlers ...Handler)

func (*Context) Set

func (c *Context) Set(key interface{}, value interface{})

func (*Context) SetLogger

func (c *Context) SetLogger(entry log.Logger)

func (*Context) String

func (c *Context) String(text string)

func (*Context) Value

func (c *Context) Value(key interface{}) interface{}

type Handler

type Handler func(*Context)

type M

type M map[string]interface{}

func HTTPHeaderToM

func HTTPHeaderToM(header http.Header) M

func (M) ForeachKey

func (m M) ForeachKey(handler func(key, val string) error) error

ForeachKey conforms to the TextMapReader interface.

func (M) Set

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

Set conforms to the TextMapWriter interface.

type MockContext

type MockContext struct {
	Response *R
}

func (*MockContext) Ack

func (m *MockContext) Ack(...interface{})

func (*MockContext) Nack

func (m *MockContext) Nack(...interface{})

func (*MockContext) Publish

func (m *MockContext) Publish(r *R)

func (*MockContext) Request

func (m *MockContext) Request() *R

type R

type R struct {
	Body        []byte
	Headers     M
	RoutingKey  string
	ContentType string
}

Jump to

Keyboard shortcuts

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