Skip to content

Commit

Permalink
fix(gen): do not get encoder from pool
Browse files Browse the repository at this point in the history
  • Loading branch information
tdakkota committed Oct 19, 2023
1 parent 6a12bb8 commit a110e71
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions gen/_template/parameter_encode.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ cookie := uri.NewCookieEncoder(r)
{{- $param := $ }}
{{- $el := elem $param.Type (printf "params.%s" $param.Name) }}
{{- if $param.Spec.Content }}
enc := jx.GetEncoder()
var enc jx.Encoder
func(e *jx.Encoder) {
{{- template "json/enc" $el }}
}(enc)
}(&enc)
return e.EncodeValue(string(enc.Bytes()))
{{- else }}
{{- template "uri/encode" $el }}
Expand Down
2 changes: 1 addition & 1 deletion gen/_template/request_encode.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func encode{{ $op.Name }}Request(
})
ht.SetCloserBody(r, body, contentType)
{{- else }}
e := jx.GetEncoder()
e := new(jx.Encoder)
{
{{- template "json/enc" elem $type "req" }}
}
Expand Down
6 changes: 3 additions & 3 deletions gen/_template/response_encode.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ func encode{{ $op.Name }}Response(response {{ $op.Responses.GoType }}, w http.Re
if err := h.EncodeParam(cfg, func(e uri.Encoder) error{
{{- $el := elem $header.Type (printf "response.%s" $header.Name) }}
{{- if $header.Spec.Content }}
enc := jx.GetEncoder()
var enc jx.Encoder
func(e *jx.Encoder) {
{{ template "json/enc" $el }}
}(enc)
}(&enc)
return e.EncodeValue(string(enc.Bytes()))
{{- else }}
{{- template "uri/encode" $el }}
Expand Down Expand Up @@ -132,7 +132,7 @@ func encode{{ $op.Name }}Response(response {{ $op.Responses.GoType }}, w http.Re
return errors.Wrap(err, "flush streaming")
}
{{- else }}
e := jx.GetEncoder()
e := new(jx.Encoder)
{{- template "json/enc" elem $type $var }}
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
Expand Down

0 comments on commit a110e71

Please sign in to comment.