mirror of
https://github.com/gofiber/fiber.git
synced 2025-07-09 03:58:51 +00:00
* feat(cbor): allow encoding response bodies in cbor * fix(tests::cbor): encode struct instead of a randomly ordered hashmap * docs(whats_new): add cbor in context section * feat(binder): introduce CBOR * feat(client): allow cbor in fiber client * chore(tests): add more test * chore(packages): go mod tidy * fix(binder): update CBOR name and test * improve test coverage * improve test coverage * update1 * add docs * doc fixes * update * Fix markdown lint * Add missing entry from binder README * add/refresh documentation --------- Co-authored-by: Juan Calderon-Perez <835733+gaby@users.noreply.github.com> Co-authored-by: M. Efe Çetin <efectn@protonmail.com> Co-authored-by: RW <rene@gofiber.io>
24 lines
458 B
Go
24 lines
458 B
Go
package binder
|
|
|
|
import (
|
|
"encoding/xml"
|
|
"fmt"
|
|
)
|
|
|
|
// xmlBinding is the XML binder for XML request body.
|
|
type xmlBinding struct{}
|
|
|
|
// Name returns the binding name.
|
|
func (*xmlBinding) Name() string {
|
|
return "xml"
|
|
}
|
|
|
|
// Bind parses the request body as XML and returns the result.
|
|
func (*xmlBinding) Bind(body []byte, out any) error {
|
|
if err := xml.Unmarshal(body, out); err != nil {
|
|
return fmt.Errorf("failed to unmarshal xml: %w", err)
|
|
}
|
|
|
|
return nil
|
|
}
|