Skip to content

Commit

Permalink
fix(hz): client cookie (#1144)
Browse files Browse the repository at this point in the history
  • Loading branch information
FGYFFFF authored Jun 26, 2024
1 parent 2a16d50 commit c562fb6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/hz/protobuf/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,10 @@ func parseAnnotationToClient(clientMethod *generator.ClientMethod, gen *protogen
val := 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)
}
Expand Down
4 changes: 4 additions & 0 deletions cmd/hz/thrift/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand Down

0 comments on commit c562fb6

Please sign in to comment.