Closed cpanato closed 3 years ago
My suggestion would be to add the content-type as a configuration item to: ControllerConfig
https://github.com/openfaas/connector-sdk/blob/master/types/controller.go#L17
This would be set statically at deploy-time for all messages sent via the invoke method.
The Controller would then pass that value on to the Invoker here:
https://github.com/openfaas/connector-sdk/blob/master/types/invoker.go#L40
I haven't seen a need from users yet, or our own use for variable content-types depending on the message topic, so let's keep it simple for iteration #1.
So to sum up: set a Content-Type configuration item via an environment variable and pass it down the stack to where it's needed. Keep everything else the same, and then update the tester example and README please.
Once the PR is up, let's get it reviewed and released so that it can be retro-fitted to the nats-connector and others like your own.
Alex
My actions before raising this issue
I did a pair session with Alex some weeks ago about the [cloudnative bot] and I added a check to validate the content type: https://github.com/cpanato/cloudnative-bot/blob/main/functions/k8s-patch-release/handler.go#L59
I disable that because looks like the connector-sdk looks like does not set the content type
I’ve made a simple project with the connector-sdk + a very simple function and i can see that is not set
I checked the code for connector-sdk and did not see anything that sets this header
Expected Behaviour
Set the content-type header header
Current Behaviour
not setting the content-type header
Possible Solution
Add and option when invoking the function to pass a set of headers that the user want to forward to the function
maybe add another parementer in the invoke function: https://github.com/openfaas/connector-sdk/blob/master/cmd/tester/main.go#L50
Steps to Reproduce (for bugs)
can use the example https://github.com/openfaas/connector-sdk/blob/master/cmd/tester/main.go to run your streaming
create a simple function the check the header and deploy it
run the service describe in item 1 and deploy item 2
Context
Your Environment
FaaS-CLI version ( Full output from:
faas-cli version
): 0.13.10-2-g6aa5d832Docker version
docker version
(e.g. Docker 17.0.05 ): 20.10.6Are you using Docker Swarm or Kubernetes (FaaS-netes)? no
Operating System and version (e.g. Linux, Windows, MacOS): linux/macos
Code example or link to GitHub repo or gist to reproduce problem: --
Other diagnostic information / logs from troubleshooting guide
Next steps
You may join Slack for community support.