Skip to content

Commit c08fff8

Browse files
authored
Merge pull request awslabs#61 from jancona/populate-RequestURI
Populate http.Request.RequestURI
2 parents 8564c1c + 64199f0 commit c08fff8

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

core/request.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ func (r *RequestAccessor) EventToRequest(req events.APIGatewayProxyRequest) (*ht
193193
for h := range req.Headers {
194194
httpRequest.Header.Add(h, req.Headers[h])
195195
}
196+
httpRequest.RequestURI = httpRequest.URL.RequestURI()
196197
return httpRequest, nil
197198
}
198199

core/request_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ var _ = Describe("RequestAccessor tests", func() {
2323
httpReq, err := accessor.EventToRequestWithContext(context.Background(), basicRequest)
2424
Expect(err).To(BeNil())
2525
Expect("/hello").To(Equal(httpReq.URL.Path))
26+
Expect("/hello").To(Equal(httpReq.RequestURI))
2627
Expect("GET").To(Equal(httpReq.Method))
2728
})
2829

@@ -32,6 +33,7 @@ var _ = Describe("RequestAccessor tests", func() {
3233
httpReq, err := accessor.ProxyEventToHTTPRequest(basicRequest)
3334
Expect(err).To(BeNil())
3435
Expect("/hello").To(Equal(httpReq.URL.Path))
36+
Expect("/hello").To(Equal(httpReq.RequestURI))
3537
Expect("GET").To(Equal(httpReq.Method))
3638
})
3739

@@ -51,6 +53,7 @@ var _ = Describe("RequestAccessor tests", func() {
5153
httpReq, err := accessor.EventToRequestWithContext(context.Background(), binaryRequest)
5254
Expect(err).To(BeNil())
5355
Expect("/hello").To(Equal(httpReq.URL.Path))
56+
Expect("/hello").To(Equal(httpReq.RequestURI))
5457
Expect("POST").To(Equal(httpReq.Method))
5558

5659
bodyBytes, err := ioutil.ReadAll(httpReq.Body)
@@ -73,6 +76,9 @@ var _ = Describe("RequestAccessor tests", func() {
7376
httpReq, err := accessor.EventToRequestWithContext(context.Background(), mqsRequest)
7477
Expect(err).To(BeNil())
7578
Expect("/hello").To(Equal(httpReq.URL.Path))
79+
Expect(httpReq.RequestURI).To(ContainSubstring("hello=1"))
80+
Expect(httpReq.RequestURI).To(ContainSubstring("world=2"))
81+
Expect(httpReq.RequestURI).To(ContainSubstring("world=3"))
7682
Expect("GET").To(Equal(httpReq.Method))
7783

7884
query := httpReq.URL.Query()
@@ -97,6 +103,8 @@ var _ = Describe("RequestAccessor tests", func() {
97103
httpReq, err := accessor.EventToRequestWithContext(context.Background(), qsRequest)
98104
Expect(err).To(BeNil())
99105
Expect("/hello").To(Equal(httpReq.URL.Path))
106+
Expect(httpReq.RequestURI).To(ContainSubstring("hello=1"))
107+
Expect(httpReq.RequestURI).To(ContainSubstring("world=2"))
100108
Expect("GET").To(Equal(httpReq.Method))
101109

102110
query := httpReq.URL.Query()
@@ -117,6 +125,7 @@ var _ = Describe("RequestAccessor tests", func() {
117125

118126
Expect(err).To(BeNil())
119127
Expect("/orders").To(Equal(httpReq.URL.Path))
128+
Expect("/orders").To(Equal(httpReq.RequestURI))
120129
})
121130

122131
contextRequest := getProxyRequest("orders", "GET")

0 commit comments

Comments
 (0)