From b79a771e9abaa1efe7551ca004a67cefd3c8f9e2 Mon Sep 17 00:00:00 2001 From: fgy Date: Wed, 26 Jun 2024 11:53:12 +0800 Subject: [PATCH] fix: client cookie --- cmd/hz/protobuf/ast.go | 4 ++++ cmd/hz/thrift/ast.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/cmd/hz/protobuf/ast.go b/cmd/hz/protobuf/ast.go index d607a8394..e11b5a043 100644 --- a/cmd/hz/protobuf/ast.go +++ b/cmd/hz/protobuf/ast.go @@ -353,6 +353,10 @@ func parseAnnotationToClient(clientMethod *generator.ClientMethod, gen *protogen val := checkSnakeName(fileAnnos.(string)) clientMethod.FormFileCode += fmt.Sprintf("%q: req.Get%s(),\n", val, f.GoName) } + if proto.HasExtension(f.Desc.Options(), api.E_Cookie) { + hasAnnotation = true + // cookie do nothing + } if !hasAnnotation && strings.EqualFold(clientMethod.HTTPMethod, "get") { clientMethod.QueryParamsCode += fmt.Sprintf("%q: req.Get%s(),\n", checkSnakeName(string(f.Desc.Name())), f.GoName) } diff --git a/cmd/hz/thrift/ast.go b/cmd/hz/thrift/ast.go index 5005a208c..5e0aec43f 100644 --- a/cmd/hz/thrift/ast.go +++ b/cmd/hz/thrift/ast.go @@ -321,6 +321,10 @@ func parseAnnotationToClient(clientMethod *generator.ClientMethod, p *parser.Typ hasFormAnnotation = true clientMethod.FormFileCode += fmt.Sprintf("%q: req.Get%s(),\n", fileName, field.GoName().String()) } + if anno := getAnnotation(field.Annotations, AnnotationCookie); len(anno) > 0 { + hasAnnotation = true + // cookie do nothing + } if !hasAnnotation && strings.EqualFold(clientMethod.HTTPMethod, "get") { clientMethod.QueryParamsCode += fmt.Sprintf("%q: req.Get%s(),\n", checkSnakeName(field.GetName()), field.GoName().String()) }