Skip to content

Commit

Permalink
Merge pull request awslabs#61 from jancona/populate-RequestURI
Browse files Browse the repository at this point in the history
Populate http.Request.RequestURI
  • Loading branch information
jt0 authored Jun 9, 2020
2 parents 8564c1c + 64199f0 commit c08fff8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ func (r *RequestAccessor) EventToRequest(req events.APIGatewayProxyRequest) (*ht
for h := range req.Headers {
httpRequest.Header.Add(h, req.Headers[h])
}
httpRequest.RequestURI = httpRequest.URL.RequestURI()
return httpRequest, nil
}

Expand Down
9 changes: 9 additions & 0 deletions core/request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var _ = Describe("RequestAccessor tests", func() {
httpReq, err := accessor.EventToRequestWithContext(context.Background(), basicRequest)
Expect(err).To(BeNil())
Expect("/hello").To(Equal(httpReq.URL.Path))
Expect("/hello").To(Equal(httpReq.RequestURI))
Expect("GET").To(Equal(httpReq.Method))
})

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

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

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

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

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

Expect(err).To(BeNil())
Expect("/orders").To(Equal(httpReq.URL.Path))
Expect("/orders").To(Equal(httpReq.RequestURI))
})

contextRequest := getProxyRequest("orders", "GET")
Expand Down

0 comments on commit c08fff8

Please sign in to comment.