Skip to content

Commit

Permalink
Copy cookies to lambda request
Browse files Browse the repository at this point in the history
  • Loading branch information
dherbst committed Nov 17, 2022
1 parent 2db1d08 commit 71b347f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lambda.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ func transformLambdaBody(resp *http.Response) error {
for k, v := range lambdaResp.Headers {
resp.Header.Set(k, v)
}
for _, c := range lambdaResp.Cookies {
resp.Header.Set("Set-Cookie", c)
}

resp.ContentLength = int64(len(bbody))
resp.Header.Set("Content-Length", fmt.Sprintf("%v", len(bbody)))

Expand All @@ -87,6 +91,8 @@ func proxyTargetLambda(ctx context.Context, target *Target) func(http.ResponseWr
req.Method = http.MethodPost
data := make(map[string]interface{})
data["rawPath"] = req.URL.Path
data["cookies"] = req.Header["Cookie"]

if r.Method == http.MethodPost {
data["requestContext"] = map[string]interface{}{"http": map[string]interface{}{"method": "POST"}}
posted, err := ioutil.ReadAll(r.Body)
Expand Down

0 comments on commit 71b347f

Please sign in to comment.