From fb758a6ad4c467a4f132d01e09d47f9700fb57d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Tue, 4 Oct 2022 00:50:27 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=B7=E6=B1=82=E6=94=AF=E6=8C=81=E4=BC=A0?= =?UTF-8?q?=E5=85=A5=E5=8A=A8=E6=80=81header?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rpc.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/rpc.go b/rpc.go index cd40a6a..fcebc6f 100644 --- a/rpc.go +++ b/rpc.go @@ -256,7 +256,7 @@ func (r *request) Get() error { // Author : go_developer@163.com<白茶清欢> // // Date : 14:24 2022/6/30 -func (r *request) Send(ctx *gin.Context, serviceFlag string, apiFlag string, parameter map[string]interface{}, receiver interface{}) error { +func (r *request) Send(ctx *gin.Context, serviceFlag string, apiFlag string, parameter map[string]interface{}, header map[string]string, receiver interface{}) error { var ( serviceConfig *Service apiConfig *Api @@ -289,8 +289,15 @@ func (r *request) Send(ctx *gin.Context, serviceFlag string, apiFlag string, par fullURL, body = r.getFullURLAndBody(serviceConfig, apiConfig, parameter) logDataList = append(logDataList, zap.String("full_utl", fullURL)) + fullHeader := make(map[string]string) + for k, v := range apiConfig.Header { + fullHeader[k] = v + } + for k, v := range header { + fullHeader[k] = v + } // 获取客户端 - client = r.GetHttpClient(apiConfig.Header, apiConfig.Timeout) + client = r.GetHttpClient(fullHeader, apiConfig.Timeout) var bodyReader io.Reader if nil != body { logDataList = append(logDataList, zap.String("request_body", string(body)))