fiber/binder/xml.go
RW fe1bf4a0b3
feat(ctx): add conditional copy helpers (#3703)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2025-08-26 07:54:15 +02:00

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
}