overflow_probes/client/data/socket_builders.go

52 lines
1.1 KiB
Go
Raw Normal View History

2017-12-02 03:13:08 +00:00
package data
2017-12-01 16:17:44 +00:00
import (
"net/http"
"git.loafle.net/commons_go/logging"
cwfc "git.loafle.net/commons_go/websocket_fasthttp/client"
2017-12-02 03:19:00 +00:00
oocmp "git.loafle.net/overflow/overflow_commons_go/modules/probe"
2017-12-01 16:17:44 +00:00
oopcc "git.loafle.net/overflow/overflow_probes/central/client"
2017-12-02 03:19:00 +00:00
oops "git.loafle.net/overflow/overflow_probes/service"
2017-12-01 16:17:44 +00:00
)
2017-12-02 03:19:00 +00:00
func NewSocketBuilder(napService *oops.NoAuthProbeService) cwfc.SocketBuilder {
2017-12-01 16:17:44 +00:00
sb := &SocketBuilders{
napService: napService,
}
2017-12-02 03:19:00 +00:00
sb.SocketBuilders = oopcc.NewSocketBuilder(oocmp.HTTPEntry_NoAuthProbe)
2017-12-01 16:17:44 +00:00
if nil == sb.SocketBuilders {
return nil
}
return sb
}
type SocketBuilders struct {
*oopcc.SocketBuilders
2017-12-02 03:19:00 +00:00
napService *oops.NoAuthProbeService
2017-12-01 16:17:44 +00:00
}
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")
}
}