-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
feat(apigatewayv2): support for setting routeSelectionExpression
for an HTTP API
#31373
Changes from 5 commits
1462826
eb1f1be
9fd9bad
eab94f8
4d62019
f9c9457
f3634b2
ee38932
4eae08d
dcbe42a
623e5fe
e699505
16684fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,6 +160,15 @@ export interface HttpApiProps { | |
* @default - no default authorization scopes | ||
*/ | ||
readonly defaultAuthorizationScopes?: string[]; | ||
|
||
/** | ||
* Whether to set the default route selection expression for the API. | ||
* | ||
* When enabled, "${request.method} ${request.path}" is set as the default route selection expression. | ||
* | ||
* @default false | ||
*/ | ||
readonly routeSelectionExpression?: boolean; | ||
} | ||
|
||
/** | ||
|
@@ -434,6 +443,7 @@ export class HttpApi extends HttpApiBase { | |
corsConfiguration, | ||
description: props?.description, | ||
disableExecuteApiEndpoint: this.disableExecuteApiEndpoint, | ||
routeSelectionExpression: props?.routeSelectionExpression === true ? '$request.method $request.path' : undefined, | ||
badmintoncryer marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why It is probably correct as the deployment has not failed. However, the CFn documentation also says it in brackets, and the selection expression guide says the following.
https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-parameter-mapping.html There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is my mistakes! Thank you for your confirmation!! |
||
}; | ||
|
||
const resource = new CfnApi(this, 'Resource', apiProps); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -234,6 +234,19 @@ describe('HttpApi', () => { | |
}); | ||
}); | ||
|
||
test('routeSelectionExpression is enabled', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Additionally, it might be good to write a test for |
||
const stack = new Stack(); | ||
new HttpApi(stack, 'api', { | ||
routeSelectionExpression: true, | ||
}); | ||
|
||
Template.fromStack(stack).hasResourceProperties('AWS::ApiGatewayV2::Api', { | ||
Name: 'api', | ||
ProtocolType: 'HTTP', | ||
RouteSelectionExpression: '$request.method $request.path', | ||
}); | ||
}); | ||
|
||
test('can add a vpc links', () => { | ||
// GIVEN | ||
const stack = new Stack(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a bit of redundancy in the first and second halves, could you simplify it a bit?