utils

package
v0.1.115 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2020 License: Apache-2.0 Imports: 8 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromContext

func FromContext(ctx context.Context, key string) string

FromContext allows for the retrieval of the specified key's value from the supplied Context. If the value is not found, an empty string is returned.

func GetRequest

func GetRequest(ctx context.Context, returnValuePointer interface{}, url string) errors.EdgeX

GetRequest will make a GET request to the specified URL, and parse the JSON-encoded response body to the value pointed to by returnValuePointer.

func PostRawDataRequest added in v0.1.115

func PostRawDataRequest(ctx context.Context, url string, data []byte) ([]byte, errors.EdgeX)

PostRawDataRequest will make a POST request to the specified URL. It returns the body as a byte array if successful and an error otherwise.

func PostRequest added in v0.1.115

func PostRequest(
	ctx context.Context,
	returnValuePointer interface{},
	url string,
	data interface{}) errors.EdgeX

Helper method to make the post JSON request and return the body

Types

type CorrelatedRequest

type CorrelatedRequest struct {
	*http.Request
}

CorrelatedRequest is a wrapper type for use in managing Correlation IDs during service to service API calls.

func NewCorrelatedRequest

func NewCorrelatedRequest(ctx context.Context, req *http.Request) CorrelatedRequest

NewCorrelatedRequest will add the Correlation ID header to the supplied request. If no Correlation ID header is present in the supplied context, one will be created along with a value.

Jump to

Keyboard shortcuts

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