@@ -18,7 +18,10 @@ import { HttpRequest } from "@aws-sdk/protocol-http";
18
18
import { HttpBindingMux , UriSpec } from "." ;
19
19
20
20
describe ( "simple matching" , ( ) => {
21
- const router = new HttpBindingMux < "Test" , "A" | "LessSpecificA" | "Greedy" | "MiddleGreedy" | "Delete" > ( [
21
+ const router = new HttpBindingMux <
22
+ "Test" ,
23
+ "A" | "LessSpecificA" | "Greedy" | "MiddleGreedy" | "Delete" | "QueryKeyOnly"
24
+ > ( [
22
25
new UriSpec ( "GET" , [ { type : "path_literal" , value : "a" } , { type : "path" } , { type : "path" } ] , [ ] , {
23
26
service : "Test" ,
24
27
operation : "A" ,
@@ -46,6 +49,10 @@ describe("simple matching", () => {
46
49
] ,
47
50
{ service : "Test" , operation : "Delete" }
48
51
) ,
52
+ new UriSpec ( "GET" , [ { type : "path_literal" , value : "query_key_only" } ] , [ { type : "query_literal" , key : "foo" } ] , {
53
+ service : "Test" ,
54
+ operation : "QueryKeyOnly" ,
55
+ } ) ,
49
56
] ) ;
50
57
51
58
const matches : { [ idx : string ] : HttpRequest [ ] } = {
@@ -68,10 +75,20 @@ describe("simple matching", () => {
68
75
new HttpRequest ( { method : "GET" , path : "/mg/a/b/c/d/z" , query : { abc : "def" } } ) ,
69
76
] ,
70
77
"Test#Delete" : [
78
+ new HttpRequest ( { method : "DELETE" , path : "/" , query : { foo : "bar" , baz : "quux" } } ) ,
79
+ new HttpRequest ( { method : "DELETE" , path : "/" , query : { foo : [ "bar" ] , baz : "quux" } } ) ,
80
+ new HttpRequest ( { method : "DELETE" , path : "/" , query : { foo : [ "bar" , "corge" ] , baz : "quux" } } ) ,
71
81
new HttpRequest ( { method : "DELETE" , path : "/" , query : { foo : "bar" , baz : "quux" } } ) ,
72
82
new HttpRequest ( { method : "DELETE" , path : "/" , query : { foo : "bar" , baz : null } } ) ,
73
83
new HttpRequest ( { method : "DELETE" , path : "" , query : { foo : "bar" , baz : [ "quux" , "grault" ] } } ) ,
74
84
] ,
85
+ "Test#QueryKeyOnly" : [
86
+ new HttpRequest ( { method : "GET" , path : "/query_key_only" , query : { foo : "bar" } } ) ,
87
+ new HttpRequest ( { method : "GET" , path : "/query_key_only" , query : { foo : null } } ) ,
88
+ new HttpRequest ( { method : "GET" , path : "/query_key_only" , query : { foo : "" } } ) ,
89
+ // this is actually what /query_key_only?foo will look like behind APIGateway
90
+ new HttpRequest ( { method : "GET" , path : "/query_key_only" , query : { foo : [ "" ] } } ) ,
91
+ ] ,
75
92
} ;
76
93
77
94
const misses = [
@@ -87,7 +104,6 @@ describe("simple matching", () => {
87
104
new HttpRequest ( { method : "GET" , path : "/mg/q" } ) ,
88
105
new HttpRequest ( { method : "GET" , path : "/mg/z" } ) ,
89
106
new HttpRequest ( { method : "GET" , path : "/mg/a/b/z/c" } ) ,
90
- new HttpRequest ( { method : "DELETE" , path : "/" , query : { foo : [ "bar" , "corge" ] , baz : "quux" } } ) ,
91
107
new HttpRequest ( { method : "DELETE" , path : "/" , query : { foo : "bar" } } ) ,
92
108
new HttpRequest ( { method : "DELETE" , path : "/" , query : { baz : "quux" } } ) ,
93
109
new HttpRequest ( { method : "DELETE" , path : "/" } ) ,
0 commit comments