File tree 2 files changed +28
-1
lines changed
packages/@aws-cdk/aws-apigateway
2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -138,9 +138,15 @@ function validateResourcePathPart(part: string) {
138
138
// strip {} which indicate this is a parameter
139
139
if ( part . startsWith ( '{' ) && part . endsWith ( '}' ) ) {
140
140
part = part . substr ( 1 , part . length - 2 ) ;
141
+
142
+ // proxy resources are allowed to end with a '+'
143
+ if ( part . endsWith ( '+' ) ) {
144
+ part = part . substr ( 0 , part . length - 1 ) ;
145
+ }
141
146
}
142
147
143
148
if ( ! / ^ [ a - z A - Z 0 - 9 \. \_ \- ] + $ / . test ( part ) ) {
144
- throw new Error ( `Resource's path part only allow a-zA-Z0-9._- and curly braces at the beginning and the end: ${ part } ` ) ;
149
+ throw new Error ( `Resource's path part only allow [a-zA-Z0-9._-], an optional trailing '+'
150
+ and curly braces at the beginning and the end: ${ part } ` ) ;
145
151
}
146
152
}
Original file line number Diff line number Diff line change @@ -223,6 +223,27 @@ export = {
223
223
test . done ( ) ;
224
224
} ,
225
225
226
+ '"addResource" allows configuration of proxy paths' ( test : Test ) {
227
+ // GIVEN
228
+ const stack = new cdk . Stack ( ) ;
229
+ const api = new apigateway . RestApi ( stack , 'restapi' , {
230
+ deploy : false ,
231
+ cloudWatchRole : false ,
232
+ restApiName : 'my-rest-api'
233
+ } ) ;
234
+
235
+ // WHEN
236
+ const proxy = api . root . addResource ( '{proxy+}' ) ;
237
+ proxy . addMethod ( 'ANY' ) ;
238
+
239
+ // THEN
240
+ expect ( stack ) . to ( haveResource ( 'AWS::ApiGateway::Resource' , {
241
+ PathPart : "{proxy+}" ,
242
+ ParentId : { "Fn::GetAtt" : [ "restapiC5611D27" , "RootResourceId" ] }
243
+ } ) ) ;
244
+ test . done ( ) ;
245
+ } ,
246
+
226
247
'"addMethod" can be used to add methods to resources' ( test : Test ) {
227
248
// GIVEN
228
249
const stack = new cdk . Stack ( ) ;
You can’t perform that action at this time.
0 commit comments