diff --git a/bootserver/controllers/client/client.go b/bootserver/controllers/client/client.go index 26a0780..350eef9 100644 --- a/bootserver/controllers/client/client.go +++ b/bootserver/controllers/client/client.go @@ -19,9 +19,9 @@ type BootController struct { l *logrus.Logger } -func NewBootController(logger *logrus.Logger) *BootController { +func NewBootController(logger *logrus.Logger, service *services.ClientHandlerService) *BootController { return &BootController{ - clientService: services.NewClientHandlerService(), + clientService: service, l: logger, } } diff --git a/bootserver/controllers/client/enroll.go b/bootserver/controllers/client/enroll.go index a68ab1f..aad8939 100644 --- a/bootserver/controllers/client/enroll.go +++ b/bootserver/controllers/client/enroll.go @@ -20,9 +20,9 @@ type EnrollController struct { l *logrus.Logger } -func NewEnrollController(l *logrus.Logger) *EnrollController { +func NewEnrollController(l *logrus.Logger, service *services.ClientHandlerService) *EnrollController { return &EnrollController{ - clientService: services.NewClientHandlerService(), + clientService: service, l: l, } } diff --git a/bootserver/middlewares/logger.go b/bootserver/middlewares/logger.go index df74f18..3acbba1 100644 --- a/bootserver/middlewares/logger.go +++ b/bootserver/middlewares/logger.go @@ -35,5 +35,5 @@ func (lm *LoggerMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request) { clientIP = "unknown" } - lm.l.Infof(`%s - [%v] "%s %s %s" %d %d`, clientIP, currentTime, method, route, httpVersion, responseInfo.ReturnCode, responseInfo.ContentLength) + lm.l.Infof(`%s - [%s] "%s %s %s" %d %d`, clientIP, currentTime.Format(time.RFC3339), method, route, httpVersion, responseInfo.ReturnCode, responseInfo.ContentLength) } diff --git a/bootserver/server/server.go b/bootserver/server/server.go index 852ef68..f50a35a 100644 --- a/bootserver/server/server.go +++ b/bootserver/server/server.go @@ -12,6 +12,7 @@ import ( "git.faercol.me/faercol/http-boot-server/bootserver/config" "git.faercol.me/faercol/http-boot-server/bootserver/controllers/client" "git.faercol.me/faercol/http-boot-server/bootserver/middlewares" + "git.faercol.me/faercol/http-boot-server/bootserver/services" "github.com/sirupsen/logrus" ) @@ -63,10 +64,10 @@ func New(appConf *config.AppConfig, logger *logrus.Logger) (*Server, error) { default: panic(fmt.Errorf("unexpected listening mode %v", appConf.ServerMode)) } - + service := services.NewClientHandlerService() controllers := map[string]http.Handler{ - client.BootRoute: middlewares.WithLogger(client.NewBootController(logger), logger), - client.EnrollRoute: middlewares.WithLogger(client.NewEnrollController(logger), logger), + client.BootRoute: middlewares.WithLogger(client.NewBootController(logger, service), logger), + client.EnrollRoute: middlewares.WithLogger(client.NewEnrollController(logger, service), logger), } m := http.NewServeMux()