RegisterHandlers 시그니쳐 변경
This commit is contained in:
11
server.go
11
server.go
@ -40,6 +40,13 @@ func init() {
|
|||||||
gob.Register([]any{})
|
gob.Register([]any{})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ServerMuxInterface interface {
|
||||||
|
http.Handler
|
||||||
|
|
||||||
|
HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
|
||||||
|
Handle(pattern string, handler http.Handler)
|
||||||
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// HTTPStatusReloginRequired : http status를 이걸 받으면 클라이언트는 로그아웃하고 로그인 화면으로 돌아가야 한다.
|
// HTTPStatusReloginRequired : http status를 이걸 받으면 클라이언트는 로그아웃하고 로그인 화면으로 돌아가야 한다.
|
||||||
HTTPStatusReloginRequired = 599
|
HTTPStatusReloginRequired = 599
|
||||||
@ -140,7 +147,7 @@ func isTlsEnabled(fileout ...*string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewHTTPServer :
|
// NewHTTPServer :
|
||||||
func NewHTTPServerWithPort(serveMux *http.ServeMux, port int) *Server {
|
func NewHTTPServerWithPort(serveMux ServerMuxInterface, port int) *Server {
|
||||||
if isTlsEnabled() && port == 80 {
|
if isTlsEnabled() && port == 80 {
|
||||||
port = 443
|
port = 443
|
||||||
}
|
}
|
||||||
@ -157,7 +164,7 @@ func NewHTTPServerWithPort(serveMux *http.ServeMux, port int) *Server {
|
|||||||
return server
|
return server
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewHTTPServer(serveMux *http.ServeMux) *Server {
|
func NewHTTPServer(serveMux ServerMuxInterface) *Server {
|
||||||
|
|
||||||
// 시작시 자동으로 enable됨
|
// 시작시 자동으로 enable됨
|
||||||
if isTlsEnabled() && *portptr == 80 {
|
if isTlsEnabled() && *portptr == 80 {
|
||||||
|
|||||||
@ -266,7 +266,7 @@ func (ws *WebsocketHandler) Cleanup() {
|
|||||||
ws.connWaitGroup.Wait()
|
ws.connWaitGroup.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ws *WebsocketHandler) RegisterHandlers(serveMux *http.ServeMux, prefix string) error {
|
func (ws *WebsocketHandler) RegisterHandlers(serveMux gocommon.ServerMuxInterface, prefix string) error {
|
||||||
url := gocommon.MakeHttpHandlerPattern(prefix, "ws")
|
url := gocommon.MakeHttpHandlerPattern(prefix, "ws")
|
||||||
if *noAuthFlag {
|
if *noAuthFlag {
|
||||||
serveMux.HandleFunc(url, ws.upgrade_nosession)
|
serveMux.HandleFunc(url, ws.upgrade_nosession)
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
|
"repositories.action2quare.com/ayo/gocommon"
|
||||||
"repositories.action2quare.com/ayo/gocommon/logger"
|
"repositories.action2quare.com/ayo/gocommon/logger"
|
||||||
"repositories.action2quare.com/ayo/gocommon/session"
|
"repositories.action2quare.com/ayo/gocommon/session"
|
||||||
|
|
||||||
@ -18,7 +19,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type WebsocketPeerHandler interface {
|
type WebsocketPeerHandler interface {
|
||||||
RegisterHandlers(serveMux *http.ServeMux, prefix string) error
|
RegisterHandlers(serveMux gocommon.ServerMuxInterface, prefix string) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type peerCtorChannelValue struct {
|
type peerCtorChannelValue struct {
|
||||||
@ -164,7 +165,7 @@ func NewWebsocketPeerHandler[T PeerInterface](consumer session.Consumer, creator
|
|||||||
return wsh
|
return wsh
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ws *websocketPeerHandler[T]) RegisterHandlers(serveMux *http.ServeMux, prefix string) error {
|
func (ws *websocketPeerHandler[T]) RegisterHandlers(serveMux gocommon.ServerMuxInterface, prefix string) error {
|
||||||
if *noAuthFlag {
|
if *noAuthFlag {
|
||||||
serveMux.HandleFunc(prefix, ws.upgrade_noauth)
|
serveMux.HandleFunc(prefix, ws.upgrade_noauth)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user