Closed JonasDoe closed 3 years ago
I'ld be willing to provide a new PR, but in that case I'ld need a preference about how to implement that. In ControllerConfig
? As an argument? In the Context
? With InvocationOptions
? In a completely different way?
This feature can solve another issue: Payload is not passed from connector to function. Event tester example doesn't work properly - body is always empty in called function.
I made it working by adding next line in invoker.go:90 (func invokefunction) httpReq.Header.Set("Content-Type", "text/plain")
Any advices?
@rshlapak-altair same issue here.
Payload is not passed from connector to function. Event tester example doesn't work properly - body is always empty in called function.
Please raise your own issue and detail everything you're using. Including the template.
At the moment there's no possibility to add HTTP header fields to the
invoke
function. I've found this issue addressing the same feature, but it was solved in a way I don't understand (afaik thehttp
package does not allow you to set header fields via theContext
) and probably solved only his own issue (the tracing). Additionally, there was already a PR with a possible solution, but it died halfway.Our case: We're working with CloudEvents and need to set the
Content-Type
toapplication/cloudevents+json
to make relating sdk (https://github.com/cloudevents/sdk-go) at the function work properly.I think the custom header fields could be set in the
ControllerConfig
, but maybe that's to general, or passed as an argument forInvoke
andInvokeWithContext
methods. Another option to keep the method's signature lean would be to support custom header fields in theContext
passed byInvokeWithContext
(a bit diverting though), or establish some kind ofInvocationOptions
type as an argument which holds custom headers and maybe other settings in future.