From 94e170df2f6ca741f8b83119029e94c334b92eb3 Mon Sep 17 00:00:00 2001 From: Harlow Ward Date: Sat, 28 Oct 2017 09:20:08 -0700 Subject: [PATCH] Initialize App when creating new server --- internal/api/httpserver.go | 2 +- internal/api/httpserver_test.go | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 internal/api/httpserver_test.go diff --git a/internal/api/httpserver.go b/internal/api/httpserver.go index 62c654b..48a8598 100644 --- a/internal/api/httpserver.go +++ b/internal/api/httpserver.go @@ -21,7 +21,7 @@ type Server struct { // New creates a new Server, initializes it and returns it. func NewHttpServer(p ProcessFunc) *Server { - api := &Server{processFunc: p} + api := &Server{processFunc: p, App: app.New()} api.Use(logger.New()) api.Post("/listen", api.requestHandler) return api diff --git a/internal/api/httpserver_test.go b/internal/api/httpserver_test.go new file mode 100644 index 0000000..94bfc37 --- /dev/null +++ b/internal/api/httpserver_test.go @@ -0,0 +1,14 @@ +package api + +import ( + "io" + "testing" +) + +func TestNewHttpServer(t *testing.T) { + fn := func(r io.ReadCloser) error { + return nil + } + + NewHttpServer(fn) +}