1
This commit is contained in:
@@ -18,6 +18,7 @@ type Server struct {
|
||||
workerPool *goroutine.Pool
|
||||
codec codec.SocketCodec
|
||||
handler handler.Handler
|
||||
discorse bool
|
||||
}
|
||||
|
||||
type Option func(*Server)
|
||||
@@ -31,6 +32,7 @@ func NewServer(options ...Option) *Server {
|
||||
workerPool: goroutine.Default(),
|
||||
bufferSize: 4096, //默认缓冲区大小
|
||||
multicore: true,
|
||||
discorse: true,
|
||||
}
|
||||
for _, option := range options {
|
||||
option(server)
|
||||
@@ -43,7 +45,11 @@ func WithSocketCodec(codec codec.SocketCodec) Option {
|
||||
u.codec = codec
|
||||
}
|
||||
}
|
||||
|
||||
func WithCORS() Option {
|
||||
return func(u *Server) {
|
||||
u.discorse = false
|
||||
}
|
||||
}
|
||||
func WithSocketHandler(handler handler.Handler) Option {
|
||||
return func(u *Server) {
|
||||
u.handler = handler
|
||||
|
||||
Reference in New Issue
Block a user