From 3d12cff53e32d2f27690ca03de700eef5ce90be7 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sun, 14 Jan 2024 22:06:18 -0500 Subject: [PATCH] refactor: use setter for the http handler --- interfaces/http.go | 1 + service/http.go | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/interfaces/http.go b/interfaces/http.go index 9e1facf..7c24cfa 100644 --- a/interfaces/http.go +++ b/interfaces/http.go @@ -10,6 +10,7 @@ import ( type HTTPService interface { Service GetHandler() *httprouter.Router + SetHttpHandler(handler HTTPHandler) } type HTTPHandler interface { diff --git a/service/http.go b/service/http.go index bdb090d..b5b464b 100644 --- a/service/http.go +++ b/service/http.go @@ -18,10 +18,13 @@ type HTTPImpl struct { handler interfaces.HTTPHandler } -func NewHTTP(node interfaces.Node, handler interfaces.HTTPHandler) interfaces.HTTPService { +func (h *HTTPImpl) SetHttpHandler(handler interfaces.HTTPHandler) { + h.handler = handler +} + +func NewHTTP(node interfaces.Node) interfaces.HTTPService { return &HTTPImpl{ - node: node, - handler: handler, + node: node, } }