diff --git a/server_handlers.go b/server_handlers.go index 6b0a6e3..331ee18 100644 --- a/server_handlers.go +++ b/server_handlers.go @@ -55,21 +55,7 @@ type ServerHandlers struct { socketHandlers map[string]SocketHandler } -func (sh *ServerHandlers) Listen() (net.Listener, error) { - return nil, errors.New("Server: Handler method[Listen] of Server is not implement") -} - -func (sh *ServerHandlers) CheckOrigin(ctx *fasthttp.RequestCtx) bool { - return true -} - -func (sh *ServerHandlers) OnError(ctx *fasthttp.RequestCtx, status int, reason error) { - logging.Logger().Error(fmt.Sprintf("Server: error status: %d, reason: %v, [%v]", status, reason, ctx)) -} - -// OnStart invoked when server is stated -// If you override ths method, must call -func (sh *ServerHandlers) OnStart() error { +func (sh *ServerHandlers) Init() error { if nil != sh.socketHandlers { for _, socketHandler := range sh.socketHandlers { if err := socketHandler.Init(); nil != err { @@ -81,6 +67,24 @@ func (sh *ServerHandlers) OnStart() error { return nil } +func (sh *ServerHandlers) Listen() (net.Listener, error) { + return nil, errors.New("Server: Handler method[Listen] of Server is not implement") +} + +// OnStart invoked when server is stated +// If you override ths method, must call +func (sh *ServerHandlers) OnStart() { + // no op +} + +func (sh *ServerHandlers) CheckOrigin(ctx *fasthttp.RequestCtx) bool { + return true +} + +func (sh *ServerHandlers) OnError(ctx *fasthttp.RequestCtx, status int, reason error) { + logging.Logger().Error(fmt.Sprintf("Server: error status: %d, reason: %v, [%v]", status, reason, ctx)) +} + // OnStop invoked when server is stopped // If you override ths method, must call func (sh *ServerHandlers) OnStop() {