mirror of
https://github.com/gofiber/fiber.git
synced 2025-09-04 19:35:47 +00:00
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
32 lines
607 B
Go
32 lines
607 B
Go
package binder
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
utils "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
|
|
}
|