Skip to content

Commit 6863c73

Browse files
author
Emil Pirfält
committed
Clean up pullrequest
1 parent 0c8fede commit 6863c73

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

handlerfunc/adapter.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import (
99

1010
type HandlerFuncAdapter struct {
1111
core.RequestAccessor
12-
handler http.Handler
12+
handlerFunc http.HandlerFunc
1313
}
1414

1515
func New(handlerFunc http.HandlerFunc) *HandlerFuncAdapter {
1616
return &HandlerFuncAdapter{
17-
handler: handlerFunc,
17+
handlerFunc: handlerFunc,
1818
}
1919
}
2020

@@ -25,7 +25,7 @@ func (h *HandlerFuncAdapter) Proxy(event events.APIGatewayProxyRequest) (events.
2525
}
2626

2727
w := core.NewProxyResponseWriter()
28-
h.handler.ServeHTTP(http.ResponseWriter(w), req)
28+
h.handlerFunc.ServeHTTP(http.ResponseWriter(w), req)
2929

3030
resp, err := w.GetProxyResponse()
3131
if err != nil {

handlerfunc/adapter_test.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,17 @@ import (
1212
. "github.com/onsi/gomega"
1313
)
1414

15-
type handler struct{}
16-
17-
func (h handler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
18-
w.Header().Add("unfortunately-required-header", "")
19-
fmt.Fprintf(w, "Go Lambda!!")
20-
}
21-
2215
var _ = Describe("HandlerFuncAdapter tests", func() {
2316
Context("Simple ping request", func() {
2417
It("Proxies the event correctly", func() {
2518
log.Println("Starting test")
2619

27-
handlerFunc := func(w http.ResponseWriter, req *http.Request) {
20+
handler := func(w http.ResponseWriter, req *http.Request) {
2821
w.Header().Add("unfortunately-required-header", "")
2922
fmt.Fprintf(w, "Go Lambda!!")
3023
}
3124

32-
adapter := handlerfunc.New(handlerFunc)
25+
adapter := handlerfunc.New(handler)
3326

3427
req := events.APIGatewayProxyRequest{
3528
Path: "/ping",

0 commit comments

Comments
 (0)