1
0
mirror of https://github.com/gofiber/fiber.git synced 2025-04-27 21:25:34 +00:00
M. Efe Çetin 57744ebbe8
🐛 bug: fix EnableSplittingOnParsers is not functional ()
* 🐛 bug: fix EnableSplittingOnParsers is not functional

* remove wrong testcase

* add support for external xml decoders

* improve test coverage

* fix linter

* update

* add reset methods

* improve test coverage

* merge Form and MultipartForm methods

* fix linter

* split reset and putting steps

* fix linter
2024-12-25 12:53:14 +01:00

32 lines
601 B
Go

package binder
import (
"fmt"
"github.com/gofiber/utils/v2"
)
// XMLBinding is the XML binder for XML request body.
type XMLBinding struct {
XMLDecoder utils.XMLUnmarshal
}
// Name returns the binding name.
func (*XMLBinding) Name() string {
return "xml"
}
// Bind parses the request body as XML and returns the result.
func (b *XMLBinding) Bind(body []byte, out any) error {
if err := b.XMLDecoder(body, out); err != nil {
return fmt.Errorf("failed to unmarshal xml: %w", err)
}
return nil
}
// Reset resets the XMLBinding binder.
func (b *XMLBinding) Reset() {
b.XMLDecoder = nil
}