|
1 | 1 | // Packge ginlambda add Gin support for the aws-severless-go-api library. |
2 | 2 | // Uses the core package behind the scenes and exposes the New method to |
3 | 3 | // get a new instance and Proxy method to send request to the Gin engine. |
4 | | -package ginlambda |
| 4 | +package ginadapter |
5 | 5 |
|
6 | 6 | import ( |
7 | | - "log" |
8 | 7 | "net/http" |
9 | 8 |
|
10 | 9 | "github.com/aws/aws-lambda-go/events" |
@@ -35,25 +34,16 @@ func (g *GinLambda) Proxy(req events.APIGatewayProxyRequest) (events.APIGatewayP |
35 | 34 | ginRequest, err := g.ProxyEventToHTTPRequest(req) |
36 | 35 |
|
37 | 36 | if err != nil { |
38 | | - log.Println("Could not convert proxy event to request") |
39 | | - log.Println(err) |
40 | | - return gatewayTimeout(), err |
| 37 | + return core.GatewayTimeout(), core.NewLoggedError("Could not convert proxy event to request: %v", err) |
41 | 38 | } |
42 | 39 |
|
43 | 40 | respWriter := core.NewProxyResponseWriter() |
44 | | - |
45 | 41 | g.ginEngine.ServeHTTP(http.ResponseWriter(respWriter), ginRequest) |
46 | 42 |
|
47 | 43 | proxyResponse, err := respWriter.GetProxyResponse() |
48 | 44 | if err != nil { |
49 | | - log.Println("Error while generating proxy response") |
50 | | - log.Println(err) |
51 | | - return gatewayTimeout(), err |
| 45 | + return core.GatewayTimeout(), core.NewLoggedError("Error while generating proxy response: %v", err) |
52 | 46 | } |
53 | | - return proxyResponse, nil |
54 | | -} |
55 | 47 |
|
56 | | -// Returns a dafault Gateway Timeout (504) response |
57 | | -func gatewayTimeout() events.APIGatewayProxyResponse { |
58 | | - return events.APIGatewayProxyResponse{StatusCode: http.StatusGatewayTimeout} |
| 48 | + return proxyResponse, nil |
59 | 49 | } |
0 commit comments