Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

fix: Updates default http output binding #308

Merged
merged 4 commits into from
Sep 5, 2019

Conversation

wbreza
Copy link
Contributor

@wbreza wbreza commented Sep 5, 2019

This updates the default value for the name of the HTTP output binding from $return to $res to work around an issue that existing within the Azure core tools http runtime..

A bug exists in the Azure core tools http runtime that evaluates $return binding incorrectly which causes serialization issues when returning arrays within an HTTP response.
Azure/azure-functions-nodejs-worker#228

@wbreza wbreza requested review from tbarlow12 and PIC123 September 5, 2019 02:45
Copy link
Contributor

@tbarlow12 tbarlow12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@PIC123 PIC123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

if (bindingUserSettings[constants.webHookType]) {
binding[constants.name] = "res";
}
binding[constants.name] = "res";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we always want it to be res, or just default to it and still have the option of choosing the $return?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need the option of choosing $return instead of res.

@wbreza wbreza merged commit 72bc900 into dev Sep 5, 2019
@wbreza wbreza deleted the wabrez/update-default-http-binding branch September 5, 2019 21:36
tbarlow12 pushed a commit that referenced this pull request Sep 13, 2019
This updates the default value for the name of the HTTP output binding from $return to $res to work around an issue that existing within the Azure core tools http runtime..

A bug exists in the Azure core tools http runtime that evaluates $return binding incorrectly which causes serialization issues when returning arrays within an HTTP response.
Azure/azure-functions-nodejs-worker#228
@wbreza
Copy link
Contributor Author

wbreza commented Dec 4, 2019

@jon-lewis Even though the default has changed to res this can always be overriden in your serverless.yml as needed for your implementation.

You can modify your handler definition to include the output binding. When you handler specifies its own output binding then the default is ignored.

  health:
    handler: src/handlers/health.handler
    events:
      - http: true
        x-azure-settings:
          methods:
            - GET
          authLevel : function
      - http: true
        x-azure-settings:
          direction: out
          name: res

Hope this helps.

@jon-lewis
Copy link

jon-lewis commented Feb 26, 2020

Perfect. I did test this out and the following settings worked for me.

- http: true
  x-azure-settings:
    direction: out
    name: $return

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

Successfully merging this pull request may close these issues.

4 participants