Skip to content

Commit

Permalink
add headers
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Bernardo committed Jun 17, 2020
1 parent d50470a commit ffd6be9
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
Binary file modified bin/darwin/awslocal
Binary file not shown.
Binary file modified bin/linux/awslocal
Binary file not shown.
1 change: 1 addition & 0 deletions internal/adapters/secondary/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func ExecuteDockerLambda(content core.ExecuteLambdaRequest) (core.ResultLambdaRe
bodyStr = strings.ReplaceAll(bodyStr, "\n", "")
contentRequest.Body = bodyStr
contentRequest.PathParameters = content.Parameters
contentRequest.Headers = content.Headers

jsonRequest, _ := json.Marshal(contentRequest)

Expand Down
14 changes: 11 additions & 3 deletions pkg/apigateway/apigateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package apigateway

import (
"fmt"
"github.com/gorilla/mux"
"github.com/lbernardo/aws-local/internal/adapters/secondary/docker"
"github.com/lbernardo/aws-local/pkg/core"
"log"
"net/http"
"strings"

"github.com/gorilla/mux"
"github.com/lbernardo/aws-local/internal/adapters/secondary/docker"
"github.com/lbernardo/aws-local/pkg/core"
)

func StartApiGateway(params ParamsApiGateway) {
Expand All @@ -25,11 +26,18 @@ func StartApiGateway(params ParamsApiGateway) {

fff := func(w http.ResponseWriter, r *http.Request) {
parameters := mux.Vars(r)
headers := map[string]string{}

for key, _ := range r.Header {
headers[key] = r.Header.Get(key)
}

result, off := docker.ExecuteDockerLambda(core.ExecuteLambdaRequest{
Volume: params.Volume,
Net: params.Network,
Handler: function,
Runtime: params.Serverless.Provider.Runtime,
Headers: headers,
Environment: params.Serverless.Provider.Environment,
Body: r.Body,
Parameters: parameters,
Expand Down
3 changes: 2 additions & 1 deletion pkg/core/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type ExecuteLambdaRequest struct {
Runtime string
Environment map[string]string
Body io.ReadCloser
Headers map[string]string
Parameters map[string]string
}

Expand All @@ -22,9 +23,9 @@ type ResultLambdaRequest struct {
type ContentRequest struct {
Body string `json:"body"`
PathParameters map[string]string `json:"pathparameters"`
Headers map[string]string `json:"headers"`
}


type Serverless struct {
Functions map[string]Functions `json:"functions"`
Provider Provider `json:"provider"`
Expand Down

0 comments on commit ffd6be9

Please sign in to comment.