request

package
v0.0.0-...-84339fa Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 8 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetValueFromHTTPRequest

func GetValueFromHTTPRequest(
	reqHeader http.Header,
	bodyBytes []byte,
	fieldSrc FieldSource,
	field string,
) (string, error)

GetValueFromHTTPRequest parses the request header / payload to retrieve the value for the given field

reqHeader - request header bodyBytes - request JSON payload fieldSrc - source of data, where the given key will be looked in,

one of `PayloadFieldSource` | `HeaderFieldSource`

field - if `fieldSrc` is `HeaderFieldSource` - name of request header

		   if `fieldSrc` is `PayloadFieldSource` - json path to the value that should
        be extracted from the request payload

func GetValueFromUPIRequest

func GetValueFromUPIRequest(
	reqHeader metadata.MD,
	req *upiv1.PredictValuesRequest,
	fieldSrc FieldSource,
	field string,
) (string, error)

GetValueFromUPIRequest retrieve the value from upi request or header depending on the value of `fieldSrc`. Valid value of `fieldSrc` are `HeaderFieldSource` and `PredictionContextSource`. If `fieldSrc` is `HeaderFieldSource`, then the value will be retrieved from `reqHeader`. If `fieldSrc` is `PredictionContextSource`, then the value will be retrieved from `prediction_context` field of the upi request `req`. Other `fieldSrc` value will produce error.

func UPIVariablesToStringMap

func UPIVariablesToStringMap(vars []*upiv1.Variable) (map[string]string, error)

UPIVariablesToStringMap convert slice of upi Variables into map of string

Types

type FieldSource

type FieldSource string

FieldSource is used to identify the source of the experiment-engine user data field

const (
	// PayloadFieldSource is used to represent the request payload
	PayloadFieldSource FieldSource = "payload"
	// HeaderFieldSource is used to represent the request header
	HeaderFieldSource FieldSource = "header"
	// PredictionContextSource is used to represent the prediction_context field in UPI request
	PredictionContextSource FieldSource = "prediction_context"
)

func GetFieldSource

func GetFieldSource(srcString string) (FieldSource, error)

GetFieldSource converts the input string to a FieldSource

Jump to

Keyboard shortcuts

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