This commit is contained in:
crusader 2018-05-11 12:55:35 +09:00
parent a3a14c0c3e
commit 9c850df9f7
2 changed files with 16 additions and 3 deletions

View File

@ -3,6 +3,9 @@ package data
import (
"fmt"
"net/http"
"net/url"
"path"
"strings"
logging "git.loafle.net/commons/logging-go"
crc "git.loafle.net/commons/rpc-go/client"
@ -13,8 +16,8 @@ import (
)
func New() (*crc.Client, error) {
config := config.GetConfig()
if nil == config {
_config := config.GetConfig()
if nil == _config {
return nil, fmt.Errorf("Config is not available")
}
@ -23,10 +26,19 @@ func New() (*crc.Client, error) {
return nil, err
}
if config.Dev {
u := url.URL{
Scheme: "ws",
Host: fmt.Sprintf("%s:%d", strings.Split(_config.Central.Address, ":")[0], 19095),
}
u.Path = path.Join(u.Path, occp.HTTPEntry_Data)
connector.URL = u.String()
}
connector.RequestHeader = func() http.Header {
header := make(map[string][]string)
header[occp.HTTPRequestHeaderKey_Probe_Method] = []string{occp.HTTPRequestHeaderValue_Probe_Method_Connect}
header[occp.HTTPRequestHeaderKey_Probe_ProbeKey] = []string{*config.Probe.Key}
header[occp.HTTPRequestHeaderKey_Probe_ProbeKey] = []string{*_config.Probe.Key}
return header
}
connector.ResponseHandler = func(res *http.Response) {

View File

@ -11,6 +11,7 @@ import (
const (
ConfigKey = "Config"
Dev = true
)
var (