Skip to content

Custom Handler how to return specific http Statuscodes and Headers #10987

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

Open
j-nierop opened this issue Apr 10, 2025 · 0 comments
Open

Custom Handler how to return specific http Statuscodes and Headers #10987

j-nierop opened this issue Apr 10, 2025 · 0 comments

Comments

@j-nierop
Copy link

j-nierop commented Apr 10, 2025

Is your question related to a specific version? If so, please specify:

No

What language does your question apply to? (e.g. C#, JavaScript, Java, All)

Rust/GO Custom Handler

Question

I want to know how I can tell the Function Host to return a specific Http statuscode and/or Http Headers to the caller of the azure function. I understand that when using "enableForwardingHttpRequest": true custom handler receives the same request that the host received and that caller receives the same response that the custom handler created (including status code and headers). However I want to use Application Insights for logging and see the request meta data generated by the function host such as the InvocationId and Claims related to the function key that was used so that I can identify which key was used which means I need to use "enableForwardingHttpRequest": false. The issue is that I can't seem to find any sources explaining how to tell the function host to return a specific http status code or headers with the response. In other words, what response does my custom handler need to return so that caller of the function sees a response with specific http status code and headers.

I understand that the contents of the body of the response that the caller of the function sees can be set by making the custom handler respond with the following application/json status code 200 response:

{
    "Outputs": {},
    "Logs": [
        "Log message 1",
        "Log message 2",
    ],
    "ReturnValue": "<body of response that the caller receives>",
}

Simply put: What would I need to change in the json response above so that the called receives for example an http 400 Bad Request and perhaps a specific set of Headers? Or am I missing something obvious?

I would also really appreciate it if someone can point me to some resources I could consult.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant