Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add steps to merge original request and enricher response headers #176

Merged
merged 2 commits into from
Mar 10, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion engines/router/missionctl/handlers/http_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ func (h *httpHandler) getPrediction(

// Enrich
var resp mchttp.Response
// Creates a new map to represent the merged headers from the original request headers + enricher response headers
postEnrichmentResponseHeader := req.Header.Clone()

payload := requestBody
if h.IsEnricherEnabled() {
resp, httpErr := h.Enrich(ctx, req.Header, payload)
Expand All @@ -100,13 +103,17 @@ func (h *httpHandler) getPrediction(
if httpErr != nil {
return nil, httpErr
}
// Merge Enricher response headers with original request headers
for key, value := range resp.Header() {
postEnrichmentResponseHeader.Set(key, value[0])
deadlycoconuts marked this conversation as resolved.
Show resolved Hide resolved
}
// No error, copy response body
payload = resp.Body()
}

// Route
var expResp *experiment.Response
expResp, resp, httpErr := h.Route(ctx, req.Header, payload)
expResp, resp, httpErr := h.Route(ctx, postEnrichmentResponseHeader, payload)
if expResp != nil {
var expErr *errors.HTTPError
if expResp.Error != "" {
Expand Down