Skip to content

Commit

Permalink
feat: add bindQuery default
Browse files Browse the repository at this point in the history
  • Loading branch information
shuai_yang committed Jul 13, 2023
1 parent bffc1a0 commit 42ef849
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions cmd/protoc-gen-go-http/httpTemplate.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,11 @@ func Register{{.ServiceType}}HTTPServer(s *http.Server, srv {{.ServiceType}}HTTP
func _{{$svrType}}_{{.Name}}{{.Num}}_HTTP_Handler(srv {{$svrType}}HTTPServer) func(ctx http.Context) error {
return func(ctx http.Context) error {
var in {{.Request}}
{{- if .HasBody}}
if err := ctx.Bind(&in{{.Body}}); err != nil {
return err
}

{{- if not (eq .Body "")}}
if err := ctx.BindQuery(&in); err != nil {
if err := ctx.BindQuery(&in{{.Body}}); err != nil {
return err
}
{{- end}}
{{- else}}
if err := ctx.BindQuery(&in{{.Body}}); err != nil {
{{- if .HasBody}}
if err := ctx.Bind(&in{{.Body}}); err != nil {
return err
}
{{- end}}
Expand Down

0 comments on commit 42ef849

Please sign in to comment.