Closed cpanato closed 3 years ago
add content-type option to send in the headers when invoking a function
design/approved
To test this you will need to do:
kind create cluster
arkade install openfaas --gateways 1 --load-balancer false
package function import ( "fmt" "log" "os" ) // Handle a serverless request func Handle(req []byte) string { log.Printf("Content Type: %s", os.Getenv("Http_Content_Type")) return fmt.Sprintf("Hello! your Content-Type is: %s", os.Getenv("Http_Content_Type")) }
and in the stack.yaml definition add the annotation
annotations: topic: "vm.powered.on"
tester
ContentType: "application/json",
&types.ControllerConfig
config := &types.ControllerConfig{ RebuildInterval: time.Millisecond * 1000, GatewayURL: "http://127.0.0.1:8080", PrintResponse: true, PrintResponseBody: true, AsyncFunctionInvocation: false, ContentType: "application/json", }
2021/06/12 17:21:19 Invoking on topic vm.powered.on - http://127.0.0.1:8080 2021/06/12 17:21:19 connector-sdk got result: [200] vm.powered.on => test.openfaas-fn (46) bytes [200] vm.powered.on => test.openfaas-fn Hello! your Content-Type is: application/json
git commit -s
Fixes: https://github.com/openfaas/connector-sdk/issues/58
Description
add content-type option to send in the headers when invoking a function
Motivation and Context
design/approved
labelHow Has This Been Tested?
To test this you will need to do:
kind create cluster
arkade install openfaas --gateways 1 --load-balancer false
and in the stack.yaml definition add the annotation
tester
code to addContentType: "application/json",
the following line in the&types.ControllerConfig
(https://github.com/openfaas/connector-sdk/blob/master/cmd/tester/main.go#L30-L36)Types of changes
Checklist:
git commit -s
Fixes: https://github.com/openfaas/connector-sdk/issues/58