package server import ( "fmt" "net" ) type ServerHandler interface { GetName() string GetMaxConnections() int ServerContext() ServerContext Init(serverCTX ServerContext) error OnStart(serverCTX ServerContext) error OnError(serverCTX ServerContext, conn net.Conn, status int, reason error) OnStop(serverCTX ServerContext) Destroy(serverCTX ServerContext) Listen(serverCTX ServerContext) (net.Listener, error) Servlet() Servlet Validate() } type ServerHandlers struct { ServerHandler Name string MaxConnections int } func (sh *ServerHandlers) ServerContext() ServerContext { return nil } func (sh *ServerHandlers) Init(serverCTX ServerContext) error { return nil } func (sh *ServerHandlers) OnStart(serverCTX ServerContext) error { return nil } func (sh *ServerHandlers) OnError(serverCTX ServerContext, conn net.Conn, status int, reason error) { } func (sh *ServerHandlers) OnStop(serverCTX ServerContext) { } func (sh *ServerHandlers) Destroy(serverCTX ServerContext) { } func (sh *ServerHandlers) Listen(serverCTX ServerContext) (net.Listener, error) { return nil, fmt.Errorf("Server: Method[ServerHandler.Listen] is not implemented") } func (sh *ServerHandlers) Servlet() Servlet { return nil } func (sh *ServerHandlers) Validate() { if "" == sh.Name { sh.Name = "Server" } if 0 >= sh.MaxConnections { sh.MaxConnections = 0 } }