This commit is contained in:
parent
9f39de9bca
commit
ad52dca10f
4 changed files with 9 additions and 8 deletions
|
@ -19,9 +19,9 @@ type BootController struct {
|
||||||
l *logrus.Logger
|
l *logrus.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewBootController(logger *logrus.Logger) *BootController {
|
func NewBootController(logger *logrus.Logger, service *services.ClientHandlerService) *BootController {
|
||||||
return &BootController{
|
return &BootController{
|
||||||
clientService: services.NewClientHandlerService(),
|
clientService: service,
|
||||||
l: logger,
|
l: logger,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,9 +20,9 @@ type EnrollController struct {
|
||||||
l *logrus.Logger
|
l *logrus.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewEnrollController(l *logrus.Logger) *EnrollController {
|
func NewEnrollController(l *logrus.Logger, service *services.ClientHandlerService) *EnrollController {
|
||||||
return &EnrollController{
|
return &EnrollController{
|
||||||
clientService: services.NewClientHandlerService(),
|
clientService: service,
|
||||||
l: l,
|
l: l,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,5 +35,5 @@ func (lm *LoggerMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
clientIP = "unknown"
|
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)
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ import (
|
||||||
"git.faercol.me/faercol/http-boot-server/bootserver/config"
|
"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/controllers/client"
|
||||||
"git.faercol.me/faercol/http-boot-server/bootserver/middlewares"
|
"git.faercol.me/faercol/http-boot-server/bootserver/middlewares"
|
||||||
|
"git.faercol.me/faercol/http-boot-server/bootserver/services"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -63,10 +64,10 @@ func New(appConf *config.AppConfig, logger *logrus.Logger) (*Server, error) {
|
||||||
default:
|
default:
|
||||||
panic(fmt.Errorf("unexpected listening mode %v", appConf.ServerMode))
|
panic(fmt.Errorf("unexpected listening mode %v", appConf.ServerMode))
|
||||||
}
|
}
|
||||||
|
service := services.NewClientHandlerService()
|
||||||
controllers := map[string]http.Handler{
|
controllers := map[string]http.Handler{
|
||||||
client.BootRoute: middlewares.WithLogger(client.NewBootController(logger), logger),
|
client.BootRoute: middlewares.WithLogger(client.NewBootController(logger, service), logger),
|
||||||
client.EnrollRoute: middlewares.WithLogger(client.NewEnrollController(logger), logger),
|
client.EnrollRoute: middlewares.WithLogger(client.NewEnrollController(logger, service), logger),
|
||||||
}
|
}
|
||||||
|
|
||||||
m := http.NewServeMux()
|
m := http.NewServeMux()
|
||||||
|
|
Loading…
Reference in a new issue