From 2bf7ef6e8a38df81c4f961445d965f31861153c5 Mon Sep 17 00:00:00 2001 From: Sinh Date: Tue, 16 Apr 2024 12:04:34 +0700 Subject: [PATCH] feat(onpoint): fix OP sign --- partnerapi/onpoint/onpoint.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/partnerapi/onpoint/onpoint.go b/partnerapi/onpoint/onpoint.go index ce2f922..f377f77 100644 --- a/partnerapi/onpoint/onpoint.go +++ b/partnerapi/onpoint/onpoint.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "net/http" + "net/url" "strconv" "strings" "time" @@ -209,17 +210,20 @@ func (c *Client) requestHttpViaNats(data model.CommunicationRequestHttp, res int if err != nil { return fmt.Errorf("onpoint: request via nats %v", err) } - qs := "" - for k, v := range data.Payload.Query { - if qs != "" { - qs += "&" - } - qs += k + "=" + v + u, err := url.ParseRequestURI(data.Payload.URL) + if err != nil { + return fmt.Errorf("onpoint: request via nats %v", err) } + q := u.Query() + for k, v := range data.Payload.Query { + q.Set(k, v) + } + u.RawQuery = q.Encode() + now := time.Now().Unix() ts := strconv.FormatInt(now, 10) arr := []string{ - qs, + u.RawQuery, data.Payload.Data, ts, } @@ -232,6 +236,7 @@ func (c *Client) requestHttpViaNats(data model.CommunicationRequestHttp, res int headerXTimestamp: ts, httputil.HeaderKeyContentType: httputil.HeaderValueApplicationJSON, } + data.Payload.Query = map[string]string{} return ec.Request(subject.Communication.RequestHTTP, data, res) }