source

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package source identifies the source of query requests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromContext

func FromContext(ctx context.Context) (interface{}, bool)

FromContext extracts the typed source, or false if it doesn't exist.

func NewContext

func NewContext(ctx context.Context, source []byte, deserialize Deserializer) (context.Context, error)

NewContext returns a new context with the source bytes as a value if the source is non-nil. If a non-nil deserializer is provided an additional typed value is added for easier use.

func RawFromContext

func RawFromContext(ctx context.Context) ([]byte, bool)

RawFromContext extracts the raw bytes of the source, or false if it doesn't exist. This is used by middleware to propagate the source across API boundaries. Application code should use FromContext.

Types

type Deserializer

type Deserializer func([]byte) (interface{}, error)

Deserializer deserializes the raw source bytes into a type for easier use. The raw source can be nil and the Deserializer can return a typed empty value for the application.

Jump to

Keyboard shortcuts

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