Adjust the position of some functions

This commit is contained in:
fredhan 2022-11-01 22:21:52 +08:00
parent 51aea73ba0
commit 90460d2688

View File

@ -18,14 +18,6 @@ func (tomlBinding) Name() string {
return "toml" 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 { func (tomlBinding) Bind(req *http.Request, obj any) error {
return decodeToml(req.Body, obj) 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 { func (tomlBinding) BindBody(body []byte, obj any) error {
return decodeToml(bytes.NewReader(body), obj) 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)
}