From 1defa20a76751b810ff8b762d3669ddcb7408c25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=85=89=E6=98=A5?= Date: Fri, 12 Aug 2022 17:44:17 +0800 Subject: [PATCH] - update request --- const.go | 2 +- service_http.authorizer_appid.go | 30 +++--------------------------- service_http.verify_ticket.go | 3 ++- 3 files changed, 6 insertions(+), 29 deletions(-) diff --git a/const.go b/const.go index b23dc43..0662686 100644 --- a/const.go +++ b/const.go @@ -8,4 +8,4 @@ const ( logTable = "wechatopen" ) -const Version = "1.0.6" +const Version = "1.0.7" diff --git a/service_http.authorizer_appid.go b/service_http.authorizer_appid.go index c95e829..3560227 100644 --- a/service_http.authorizer_appid.go +++ b/service_http.authorizer_appid.go @@ -1,13 +1,13 @@ package wechatopen import ( + "context" "errors" "net/http" - "strconv" ) // ServeHttpAuthorizerAppid 授权跳转 -func (c *Client) ServeHttpAuthorizerAppid(r *http.Request) (resp CgiBinComponentApiQueryAuthResponse, agentUserId string, err error) { +func (c *Client) ServeHttpAuthorizerAppid(ctx context.Context, r *http.Request) (resp CgiBinComponentApiQueryAuthResponse, agentUserId string, err error) { var ( query = r.URL.Query() @@ -25,34 +25,10 @@ func (c *Client) ServeHttpAuthorizerAppid(r *http.Request) (resp CgiBinComponent return resp, agentUserId, errors.New("找不到过期时间参数") } - info := c.CgiBinComponentApiQueryAuth(authCode) + info := c.CgiBinComponentApiQueryAuth(ctx, authCode) if info.Result.AuthorizationInfo.AuthorizerAppid == "" { return resp, agentUserId, errors.New("获取失败") } return info.Result, agentUserId, nil } - -// ToFloat64 string到float64 -func ToFloat64(s string) float64 { - i, _ := strconv.ParseFloat(s, 64) - return i -} - -// ToInt64 string到int64 -func ToInt64(s string) int64 { - i, err := strconv.ParseInt(s, 10, 64) - if err == nil { - return i - } - return int64(ToFloat64(s)) -} - -// ToUint string到uint64 -func ToUint(s string) uint { - i, err := strconv.ParseUint(s, 10, 64) - if err == nil { - return uint(i) - } - return 0 -} diff --git a/service_http.verify_ticket.go b/service_http.verify_ticket.go index 69aafc9..b6d635e 100644 --- a/service_http.verify_ticket.go +++ b/service_http.verify_ticket.go @@ -1,6 +1,7 @@ package wechatopen import ( + "context" "encoding/base64" "encoding/xml" "errors" @@ -26,7 +27,7 @@ type cipherRequestHttpBody struct { } // ServeHttpVerifyTicket 验证票据推送 -func (c *Client) ServeHttpVerifyTicket(r *http.Request) (resp *ResponseServeHttpVerifyTicket, err error) { +func (c *Client) ServeHttpVerifyTicket(ctx context.Context, r *http.Request) (resp *ResponseServeHttpVerifyTicket, err error) { var ( query = r.URL.Query()