mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
fix naming convention.
This commit is contained in:
parent
e4864b095e
commit
dd8867615e
@ -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
12
neko.go
@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user