overflow_probes/auth/client/socket_builders.go

52 lines
1.1 KiB
Go
Raw Normal View History

2017-12-01 13:01:46 +00:00
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"
2017-12-01 16:14:22 +00:00
oopar "git.loafle.net/overflow/overflow_probes/auth/rpc"
2017-12-01 13:01:46 +00:00
oopcc "git.loafle.net/overflow/overflow_probes/central/client"
)
2017-12-01 16:14:22 +00:00
func NewSocketBuilder(napService *oopar.NoAuthProbeService) cwfc.SocketBuilder {
2017-12-01 13:01:46 +00:00
sb := &SocketBuilders{
2017-12-01 16:14:22 +00:00
napService: napService,
2017-12-01 13:01:46 +00:00
}
sb.SocketBuilders = oopcc.NewSocketBuilder(oocmn.HTTPEntry_NoAuthProbe)
if nil == sb.SocketBuilders {
return nil
}
return sb
}
type SocketBuilders struct {
*oopcc.SocketBuilders
2017-12-01 16:14:22 +00:00
napService *oopar.NoAuthProbeService
2017-12-01 13:01:46 +00:00
}
func (sb *SocketBuilders) SocketHandler() cwfc.SocketHandler {
2017-12-01 16:14:22 +00:00
return newSocketHandler(sb.napService)
2017-12-01 13:01:46 +00:00
}
func (sb *SocketBuilders) GetRequestHeader() http.Header {
2017-12-01 16:14:22 +00:00
h := sb.napService.GetRequestHeader()
header := http.Header{}
for k, v := range h {
header[k] = v
2017-12-01 13:01:46 +00:00
}
2017-12-01 16:14:22 +00:00
return header
2017-12-01 13:01:46 +00:00
}
func (sb *SocketBuilders) Validate() {
sb.SocketBuilders.Validate()
2017-12-01 16:14:22 +00:00
if nil == sb.napService {
logging.Logger().Panic("Auth: NoAuthProbeService must be specified")
2017-12-01 13:01:46 +00:00
}
}