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"
|
"demodesk/neko/internal/http/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ServerCtx struct {
|
type HttpManagerCtx struct {
|
||||||
logger zerolog.Logger
|
logger zerolog.Logger
|
||||||
router *chi.Mux
|
router *chi.Mux
|
||||||
http *http.Server
|
http *http.Server
|
||||||
conf *config.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()
|
logger := log.With().Str("module", "http").Logger()
|
||||||
|
|
||||||
router := chi.NewRouter()
|
router := chi.NewRouter()
|
||||||
@ -63,7 +63,7 @@ func New(WebSocketManager types.WebSocketManager, ApiManager types.ApiManager, c
|
|||||||
Handler: router,
|
Handler: router,
|
||||||
}
|
}
|
||||||
|
|
||||||
return &ServerCtx{
|
return &HttpManagerCtx{
|
||||||
logger: logger,
|
logger: logger,
|
||||||
router: router,
|
router: router,
|
||||||
http: http,
|
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 != "" {
|
if s.conf.Cert != "" && s.conf.Key != "" {
|
||||||
go func() {
|
go func() {
|
||||||
if err := s.http.ListenAndServeTLS(s.conf.Cert, s.conf.Key); err != http.ErrServerClosed {
|
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())
|
return s.http.Shutdown(context.Background())
|
||||||
}
|
}
|
12
neko.go
12
neko.go
@ -120,7 +120,7 @@ type Neko struct {
|
|||||||
sessionManager *session.SessionManagerCtx
|
sessionManager *session.SessionManagerCtx
|
||||||
webSocketManager *websocket.WebSocketManagerCtx
|
webSocketManager *websocket.WebSocketManagerCtx
|
||||||
apiManager *api.ApiManagerCtx
|
apiManager *api.ApiManagerCtx
|
||||||
server *http.ServerCtx
|
httpManager *http.HttpManagerCtx
|
||||||
}
|
}
|
||||||
|
|
||||||
func (neko *Neko) Preflight() {
|
func (neko *Neko) Preflight() {
|
||||||
@ -167,12 +167,12 @@ func (neko *Neko) Start() {
|
|||||||
neko.Configs.Server,
|
neko.Configs.Server,
|
||||||
)
|
)
|
||||||
|
|
||||||
neko.server = http.New(
|
neko.httpManager = http.New(
|
||||||
neko.webSocketManager,
|
neko.webSocketManager,
|
||||||
neko.apiManager,
|
neko.apiManager,
|
||||||
neko.Configs.Server,
|
neko.Configs.Server,
|
||||||
)
|
)
|
||||||
neko.server.Start()
|
neko.httpManager.Start()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (neko *Neko) Shutdown() {
|
func (neko *Neko) Shutdown() {
|
||||||
@ -200,10 +200,10 @@ func (neko *Neko) Shutdown() {
|
|||||||
neko.logger.Debug().Msg("websocket manager shutdown")
|
neko.logger.Debug().Msg("websocket manager shutdown")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := neko.server.Shutdown(); err != nil {
|
if err := neko.httpManager.Shutdown(); err != nil {
|
||||||
neko.logger.Err(err).Msg("server shutdown with an error")
|
neko.logger.Err(err).Msg("http manager shutdown with an error")
|
||||||
} else {
|
} else {
|
||||||
neko.logger.Debug().Msg("server shutdown")
|
neko.logger.Debug().Msg("http manager shutdown")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user