Skip to content

Conversation

everyplace
Copy link
Contributor

@everyplace everyplace commented Sep 26, 2025

This PR adds an APIGateway V1 example, which differs slightly from the existing V2 example.

Motivation:

While APIGatewayV2 has existed for a while, there are still some scenarios where V1 is preferable (see Choose between REST APIs and HTTP APIs for more details). This PR adds a working example for the Api endpoint type.

Modifications:

Sources/main.swift

  • Swapped APIGatewayRequestV2 and APIGatewayResponseV2 for their unversioned counterparts (aka V1).

template.yaml

  • Changed the Events name and corresponding Type: Api values.
  • Added necessary additional properties to define a GET endpoint for an Api endpoint.

Readme.md

  • Updated the request and response example outputs.

Result:

Now, an APIGateway and APIGatewayV1 example exist.

Note

It is the author's opinion that this new example should technically be called APIGateway and the existing one should be renamed to APIGatewayV2 to keep consistent with the request and response type naming conventions, but this is omitted from this request to be less disruptive.

@sebsto sebsto self-assigned this Sep 26, 2025
@sebsto sebsto added the 🆕 semver/minor Adds new public API. label Sep 26, 2025
@sebsto sebsto added this to the 2.0 milestone Sep 26, 2025
@sebsto
Copy link
Contributor

sebsto commented Sep 26, 2025

Thank you for this PR.
Congrats for submitting a PR that passes all the tests at first attempt :-)

I suggested two minor changes in the review.

Can you also add this test to the CI (this line)?

I like your suggestion to rename to existing APIGateway example to ...V2. Let's keep this one as ...V1, so, at the end, we will have Examples/APIGatewayV1 and Examples/APIGatewayV2 and Examples/APIGatewayV2+LambdaAuthorizer

If you have time, can you submit a PR for this change too (don't forget to change the CI too :-) )

Copy link
Contributor

@sebsto sebsto left a comment

Choose a reason for hiding this comment

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

LGTM, just two tiny changes

//
// This source file is part of the SwiftAWSLambdaRuntime open source project
//
// Copyright (c) 2024 Apple Inc. and the SwiftAWSLambdaRuntime project authors
Copy link
Contributor

Choose a reason for hiding this comment

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

I would update this to 2025

Timeout: 60
Handler: swift.bootstrap # ignored by the Swift runtime
Runtime: provided.al2
MemorySize: 512
Copy link
Contributor

@sebsto sebsto Sep 26, 2025

Choose a reason for hiding this comment

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

I know it's coming from the example you copied, but I would use 128Mb here. This is enough to run the function and it reduces costs for customers.
I will add a GH issue to remember doing the same on all SAM examples.

Copy link
Contributor

Choose a reason for hiding this comment

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

@sebsto sebsto added 🔨 semver/patch No public API change. and removed 🆕 semver/minor Adds new public API. labels Sep 26, 2025
@everyplace everyplace requested a review from sebsto September 26, 2025 12:10
Copy link
Contributor

@sebsto sebsto left a comment

Choose a reason for hiding this comment

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

Thank you !

@sebsto sebsto enabled auto-merge (squash) September 26, 2025 12:12
@sebsto sebsto merged commit d8aa38b into swift-server:main Sep 26, 2025
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 semver/patch No public API change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants