Skip to content
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

Properties of HTTPResponses are now var #176

Merged
merged 1 commit into from
Oct 13, 2020

Conversation

fabianfett
Copy link
Member

Properties of HTTPResponse types should be var not let

Motivation:

When creating responses in Lambda developers might want to create the response in multiple steps changing and adding properties. As of now this is not possible since all HTTPResponse types only have let properties. If a developer wants to mark a response as immutable they have still the option to mark the complete response as let.

Modifications:

  • All properties of HTTPResponse types (APIGateway.Response, APIGateway.V2.Response, ALB.TargetGroupResponse) are now variable
  • An unsupported property has been removed from APIGateway.V2.Response. See example/documentation at the very end

Result:

Developers have an easier job creating responses. 🥳

Copy link
Contributor

@ktoso ktoso left a comment

Choose a reason for hiding this comment

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

Looks good to me, chatted about this before a bit


public init(
statusCode: HTTPResponseStatus,
headers: HTTPHeaders? = nil,
multiValueHeaders: HTTPMultiValueHeaders? = nil,
Copy link
Contributor

Choose a reason for hiding this comment

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

not needed any longer?

Copy link
Member Author

Choose a reason for hiding this comment

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

It never was supported in the first place. My mistake. Quote from docu:

To customize the response, your Lambda function should return a response with the following format.hv

{
   "cookies" : ["cookie1", "cookie2"],
   "isBase64Encoded": true|false,
   "statusCode": httpStatusCode,
   "headers": { "headerName": "headerValue", ... },
   "body": "Hello from Lambda!"
}     

Copy link
Contributor

Choose a reason for hiding this comment

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

sounds good, need to point out in the release notes

Copy link
Contributor

@tomerd tomerd left a comment

Choose a reason for hiding this comment

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

looks good. one question re. change in API

@tomerd tomerd added this to the 0.4.0 milestone Oct 13, 2020
@tomerd tomerd merged commit edef036 into swift-server:main Oct 13, 2020
@fabianfett fabianfett deleted the ff-var-http-responses branch October 14, 2020 06:41
stevapple added a commit to stevapple/swift-tencent-scf-runtime that referenced this pull request Jun 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants