Adjust the position of some functions (#3385)
Co-authored-by: fredhan <fredhan@futunn.com>
This commit is contained in:
parent
97082f8acc
commit
1660995a04
@ -18,14 +18,6 @@ func (tomlBinding) Name() string {
|
||||
return "toml"
|
||||
}
|
||||
|
||||
func decodeToml(r io.Reader, obj any) error {
|
||||
decoder := toml.NewDecoder(r)
|
||||
if err := decoder.Decode(obj); err != nil {
|
||||
return err
|
||||
}
|
||||
return decoder.Decode(obj)
|
||||
}
|
||||
|
||||
func (tomlBinding) Bind(req *http.Request, obj any) error {
|
||||
return decodeToml(req.Body, obj)
|
||||
}
|
||||
@ -33,3 +25,11 @@ func (tomlBinding) Bind(req *http.Request, obj any) error {
|
||||
func (tomlBinding) BindBody(body []byte, obj any) error {
|
||||
return decodeToml(bytes.NewReader(body), obj)
|
||||
}
|
||||
|
||||
func decodeToml(r io.Reader, obj any) error {
|
||||
decoder := toml.NewDecoder(r)
|
||||
if err := decoder.Decode(obj); err != nil {
|
||||
return err
|
||||
}
|
||||
return decoder.Decode(obj)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user