overflow_probes/client/central/file/socket_builders.go
crusader 9c89a2fe90 ing
2017-12-05 17:21:47 +09:00

52 lines
1.1 KiB
Go

package file
import (
"net/http"
"git.loafle.net/commons_go/logging"
cwfc "git.loafle.net/commons_go/websocket_fasthttp/client"
oocmp "git.loafle.net/overflow/overflow_commons_go/modules/probe"
oopcc "git.loafle.net/overflow/overflow_probes/central/client"
oops "git.loafle.net/overflow/overflow_probes/service"
)
func NewSocketBuilder(napService *oops.NoAuthProbeService) cwfc.SocketBuilder {
sb := &SocketBuilders{
napService: napService,
}
sb.SocketBuilders = oopcc.NewSocketBuilder(oocmp.HTTPEntry_NoAuthProbe)
if nil == sb.SocketBuilders {
return nil
}
return sb
}
type SocketBuilders struct {
*oopcc.SocketBuilders
napService *oops.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")
}
}