Skip to content

Commit

Permalink
Extract all form fields even if some fail
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanBaulch committed Oct 30, 2024
1 parent 8326630 commit 70ded83
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions encoding/form/proto_encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ func EncodeValues(msg interface{}) (url.Values, error) {
if v, ok := msg.(proto.Message); ok {
u := make(url.Values)
err := encodeByField(u, "", v.ProtoReflect())
if err != nil {
return nil, err
}
return u, nil
return u, err
}
return encoder.Encode(msg)
}
Expand Down Expand Up @@ -56,7 +53,6 @@ func encodeByField(u url.Values, path string, m protoreflect.Message) (finalErr
list, err := encodeRepeatedField(fd, v.List())
if err != nil {
finalErr = err
return false
}
for _, item := range list {
u.Add(newPath, item)
Expand All @@ -67,7 +63,6 @@ func encodeByField(u url.Values, path string, m protoreflect.Message) (finalErr
m, err := encodeMapField(fd, v.Map())
if err != nil {
finalErr = err
return false
}
for k, value := range m {
u.Set(fmt.Sprintf("%s[%s]", newPath, k), value)
Expand All @@ -81,13 +76,11 @@ func encodeByField(u url.Values, path string, m protoreflect.Message) (finalErr
}
if err = encodeByField(u, newPath, v.Message()); err != nil {
finalErr = err
return false
}
default:
value, err := EncodeField(fd, v)
if err != nil {
finalErr = err
return false
}
u.Set(newPath, value)
}
Expand Down

0 comments on commit 70ded83

Please sign in to comment.