diff --git a/backend/controller/ingress/alias.go b/backend/controller/ingress/alias.go index 8f678d9aa1..b73f92c9f9 100644 --- a/backend/controller/ingress/alias.go +++ b/backend/controller/ingress/alias.go @@ -2,6 +2,7 @@ package ingress import ( "fmt" + "reflect" "github.com/TBD54566975/ftl/backend/schema" ) @@ -25,11 +26,14 @@ func transformAliasedFields(sch *schema.Schema, t schema.Type, obj any, aliaser } case *schema.Array: - a, ok := obj.([]any) - if !ok { + // Using reflection here because not all arrays are type any. + v := reflect.ValueOf(obj) + if v.Kind() != reflect.Slice { return fmt.Errorf("expected array, got %T", obj) } - for _, elem := range a { + + for i := 0; i < v.Len(); i++ { + elem := v.Index(i).Interface() if err := transformAliasedFields(sch, t.Element, elem, aliaser); err != nil { return err } diff --git a/backend/controller/ingress/request.go b/backend/controller/ingress/request.go index 6d243a49db..4d96720ad1 100644 --- a/backend/controller/ingress/request.go +++ b/backend/controller/ingress/request.go @@ -31,7 +31,7 @@ func BuildRequestBody(route *dal.IngressRoute, r *http.Request, sch *schema.Sche var requestMap map[string]any if metadata, ok := verb.GetMetadataIngress().Get(); ok && metadata.Type == "http" { - pathParameters := map[string]string{} + pathParameters := map[string]any{} matchSegments(route.Path, r.URL.Path, func(segment, value string) { pathParameters[segment] = value }) @@ -41,12 +41,22 @@ func BuildRequestBody(route *dal.IngressRoute, r *http.Request, sch *schema.Sche return nil, err } + queryMap := make(map[string]any) + for key, values := range r.URL.Query() { + queryMap[key] = values + } + + headerMap := make(map[string]any) + for key, values := range r.Header { + headerMap[key] = values + } + requestMap = map[string]any{} requestMap["method"] = r.Method requestMap["path"] = r.URL.Path requestMap["pathParameters"] = pathParameters - requestMap["query"] = r.URL.Query() - requestMap["headers"] = r.Header + requestMap["query"] = queryMap + requestMap["headers"] = headerMap requestMap["body"] = httpRequestBody } else { var err error diff --git a/integration/integration_test.go b/integration/integration_test.go index a0dcf8749f..24a59bb36f 100644 --- a/integration/integration_test.go +++ b/integration/integration_test.go @@ -440,7 +440,6 @@ func httpCall(rd runtimeData, method string, path string, body []byte, onRespons bodyBytes, err := io.ReadAll(resp.Body) assert.NoError(t, err) - fmt.Printf("%s\n", bodyBytes) var resBody map[string]any // ignore the error here since some responses are just `[]byte`.