overflow_probes/auth/client/socket_builders.go
crusader 47d4a0b57d ing
2017-12-05 19:02:58 +09:00

52 lines
1.1 KiB
Go

package client
import (
"net/http"
"git.loafle.net/commons_go/logging"
cwfc "git.loafle.net/commons_go/websocket_fasthttp/client"
oocmn "git.loafle.net/overflow/overflow_commons_go/modules/noauthprobe"
oopas "git.loafle.net/overflow/overflow_probes/auth/service"
oopccc "git.loafle.net/overflow/overflow_probes/commons/central/client"
)
func NewSocketBuilder(napService *oopas.NoAuthProbeService) cwfc.SocketBuilder {
sb := &SocketBuilders{
napService: napService,
}
sb.SocketBuilders = oopccc.NewSocketBuilder(oocmn.HTTPEntry_NoAuthProbe)
if nil == sb.SocketBuilders {
return nil
}
return sb
}
type SocketBuilders struct {
*oopccc.SocketBuilders
napService *oopas.NoAuthProbeService
}
func (sb *SocketBuilders) SocketHandler() cwfc.SocketHandler {
return newSocketHandler(sb.napService)
}
func (sb *SocketBuilders) GetRequestHeader() http.Header {
h := sb.napService.GetRequestHeader()
header := http.Header{}
for k, v := range h {
header[k] = v
}
return header
}
func (sb *SocketBuilders) Validate() {
sb.SocketBuilders.Validate()
if nil == sb.napService {
logging.Logger().Panic("Auth: NoAuthProbeService must be specified")
}
}