Documentation
¶
Index ¶
- func GetValueFromHTTPRequest(reqHeader http.Header, bodyBytes []byte, fieldSrc FieldSource, field string) (string, error)
- func GetValueFromUPIRequest(reqHeader metadata.MD, req *upiv1.PredictValuesRequest, fieldSrc FieldSource, ...) (string, error)
- func UPIVariablesToStringMap(vars []*upiv1.Variable) (map[string]string, error)
- type FieldSource
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.
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