fix naming convention.

This commit is contained in:
Miroslav Šedivý 2020-11-13 17:34:53 +01:00
parent e4864b095e
commit dd8867615e
3 changed files with 11 additions and 11 deletions

View File

@ -16,14 +16,14 @@ import (
"demodesk/neko/internal/http/endpoint"
)
type ServerCtx struct {
type HttpManagerCtx struct {
logger zerolog.Logger
router *chi.Mux
http *http.Server
conf *config.Server
}
func New(WebSocketManager types.WebSocketManager, ApiManager types.ApiManager, conf *config.Server) *ServerCtx {
func New(WebSocketManager types.WebSocketManager, ApiManager types.ApiManager, conf *config.Server) *HttpManagerCtx {
logger := log.With().Str("module", "http").Logger()
router := chi.NewRouter()
@ -63,7 +63,7 @@ func New(WebSocketManager types.WebSocketManager, ApiManager types.ApiManager, c
Handler: router,
}
return &ServerCtx{
return &HttpManagerCtx{
logger: logger,
router: router,
http: http,
@ -71,7 +71,7 @@ func New(WebSocketManager types.WebSocketManager, ApiManager types.ApiManager, c
}
}
func (s *ServerCtx) Start() {
func (s *HttpManagerCtx) Start() {
if s.conf.Cert != "" && s.conf.Key != "" {
go func() {
if err := s.http.ListenAndServeTLS(s.conf.Cert, s.conf.Key); err != http.ErrServerClosed {
@ -89,6 +89,6 @@ func (s *ServerCtx) Start() {
}
}
func (s *ServerCtx) Shutdown() error {
func (s *HttpManagerCtx) Shutdown() error {
return s.http.Shutdown(context.Background())
}

12
neko.go
View File

@ -120,7 +120,7 @@ type Neko struct {
sessionManager *session.SessionManagerCtx
webSocketManager *websocket.WebSocketManagerCtx
apiManager *api.ApiManagerCtx
server *http.ServerCtx
httpManager *http.HttpManagerCtx
}
func (neko *Neko) Preflight() {
@ -167,12 +167,12 @@ func (neko *Neko) Start() {
neko.Configs.Server,
)
neko.server = http.New(
neko.httpManager = http.New(
neko.webSocketManager,
neko.apiManager,
neko.Configs.Server,
)
neko.server.Start()
neko.httpManager.Start()
}
func (neko *Neko) Shutdown() {
@ -200,10 +200,10 @@ func (neko *Neko) Shutdown() {
neko.logger.Debug().Msg("websocket manager shutdown")
}
if err := neko.server.Shutdown(); err != nil {
neko.logger.Err(err).Msg("server shutdown with an error")
if err := neko.httpManager.Shutdown(); err != nil {
neko.logger.Err(err).Msg("http manager shutdown with an error")
} else {
neko.logger.Debug().Msg("server shutdown")
neko.logger.Debug().Msg("http manager shutdown")
}
}