contenttypes

package
v2.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromBinary

func FromBinary(data any, target any) error

FromBinary deserializes binary response data into a byte slice target. The target must be a non-nil pointer to []byte. Returns an error if conversion fails.

func FromFormData

func FromFormData(formData []byte, dest interface{}) error

FromFormData deserializes multipart/form-data into a struct. Uses 'form' tags to map form fields to struct fields. Supports string, int, float, and bool types.

func FromFormUrlEncoded

func FromFormUrlEncoded(data []byte, target any) error

FromFormUrlEncoded deserializes URL-encoded form data into a struct. Uses struct field json tags to map form keys to struct fields. Only string fields are supported.

func FromJSON

func FromJSON(data []byte, target any) error

FromJSON deserializes JSON data from HTTP response bodies into the target struct. Uses the custom unmarshal package to handle complex types and validations.

func FromText

func FromText[T any](data []byte, target any) error

FromText deserializes plain text response data into a string target. The target must be a non-nil pointer to a string. Returns an error for unsupported types.

func FromXML

func FromXML(data []byte, target any) error

FromXML deserializes XML data from HTTP response bodies into the target struct. Uses the standard encoding/xml package for unmarshaling.

func ToBinary

func ToBinary(data any) (*bytes.Reader, error)

ToBinary serializes byte slice data for binary request bodies. Returns an error if the data is not a []byte.

func ToFormData

func ToFormData(data interface{}) (*bytes.Reader, string, error)

ToFormData converts structs and primitives to multipart/form-data format for request bodies. Returns the encoded data, Content-Type header with boundary, and any error. Supports nested structs and byte arrays.

func ToFormUrlEncoded

func ToFormUrlEncoded(data any) (*bytes.Reader, error)

ToFormUrlEncoded serializes a struct to URL-encoded form format for request bodies. Uses struct field json tags as form keys. Supports string, int, float, and bool types.

func ToJSON

func ToJSON(data any) (*bytes.Reader, error)

ToJSON serializes data to JSON format for HTTP request bodies. Returns a bytes.Reader containing the JSON-encoded data, or nil if data is nil.

func ToText

func ToText(data any) (*bytes.Reader, error)

ToText serializes string data to bytes for text/plain request bodies. Returns an error if the data is not a string.

func ToXML

func ToXML(data any) (*bytes.Reader, error)

ToXML serializes data to XML format for HTTP request bodies. Returns a bytes.Reader containing the XML-encoded data, or nil if data is nil.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL