From 4d5dea3f21ca2e62881b3daf1b37b88881860d1b Mon Sep 17 00:00:00 2001 From: crusader Date: Fri, 10 Nov 2017 18:49:19 +0900 Subject: [PATCH] ing --- server_handlers.go | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) 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() {