|
|
@ -47,12 +47,8 @@ func (h *HTTPTransport) nextID() uint64 {
|
|
|
|
return h.nextid
|
|
|
|
return h.nextid
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (h *HTTPTransport) Call(method string, args interface{}, reply interface{}) error {
|
|
|
|
|
|
|
|
return h.CallWithHeader(method, args, reply, nil)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Call call a remote method
|
|
|
|
// Call call a remote method
|
|
|
|
func (h *HTTPTransport) CallWithHeader(method string, args interface{}, reply interface{}, header http.Header) error {
|
|
|
|
func (h *HTTPTransport) Call(method string, args interface{}, reply interface{}) error {
|
|
|
|
if args == nil {
|
|
|
|
if args == nil {
|
|
|
|
args = []string{}
|
|
|
|
args = []string{}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -61,7 +57,7 @@ func (h *HTTPTransport) CallWithHeader(method string, args interface{}, reply in
|
|
|
|
Version: "2.0",
|
|
|
|
Version: "2.0",
|
|
|
|
Method: method,
|
|
|
|
Method: method,
|
|
|
|
Params: args,
|
|
|
|
Params: args,
|
|
|
|
ID: h.nextID(),
|
|
|
|
ID: fmt.Sprintf("%d", h.nextID()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
data, err := json.Marshal(r)
|
|
|
|
data, err := json.Marshal(r)
|
|
|
@ -78,14 +74,6 @@ func (h *HTTPTransport) CallWithHeader(method string, args interface{}, reply in
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if header != nil {
|
|
|
|
|
|
|
|
for k, v := range header {
|
|
|
|
|
|
|
|
for _, v1 := range v {
|
|
|
|
|
|
|
|
req.Header.Add(k, v1)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
req.Header.Set("Content-Type", "application/json")
|
|
|
|
req.Header.Set("Content-Type", "application/json")
|
|
|
|
|
|
|
|
|
|
|
|
resp, err := h.Client.Do(req)
|
|
|
|
resp, err := h.Client.Do(req)
|
|
|
|