overflow_probes/auth/client/socket_builders.go

49 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-02 03:13:08 +00:00
oopas "git.loafle.net/overflow/overflow_probes/auth/service"
2017-12-05 10:02:58 +00:00
oopccc "git.loafle.net/overflow/overflow_probes/commons/central/client"
2017-12-01 13:01:46 +00:00
)
2017-12-02 03:13:08 +00:00
func NewSocketBuilder(napService *oopas.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
}
2017-12-05 10:02:58 +00:00
sb.SocketBuilders = oopccc.NewSocketBuilder(oocmn.HTTPEntry_NoAuthProbe)
2017-12-01 13:01:46 +00:00
if nil == sb.SocketBuilders {
return nil
}
2017-12-08 08:31:45 +00:00
sb.SocketHandler = newSocketHandler(sb.napService)
2017-12-01 13:01:46 +00:00
return sb
}
type SocketBuilders struct {
2017-12-05 10:02:58 +00:00
*oopccc.SocketBuilders
2017-12-01 13:01:46 +00:00
2017-12-02 03:13:08 +00:00
napService *oopas.NoAuthProbeService
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 {
2018-03-21 10:22:13 +00:00
logging.Logger().Panicf("Auth: NoAuthProbeService must be specified")
2017-12-01 13:01:46 +00:00
}
}