overflow_probes/auth/client/socket_builders.go
crusader 94a4f3136c ing
2018-03-21 19:22:13 +09:00

49 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
}
sb.SocketHandler = newSocketHandler(sb.napService)
return sb
}
type SocketBuilders struct {
*oopccc.SocketBuilders
napService *oopas.NoAuthProbeService
}
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().Panicf("Auth: NoAuthProbeService must be specified")
}
}