Documentation
¶
Index ¶
- func Decode[T any](body io.Reader) (T, error)
- func DecodeBytes[T any](body []byte) (T, error)
- func Encode[T any](v T, w io.Writer) error
- func ParseResponse[T any](response *http.Response) (T, error)
- func StructToMultipartForm(s any) (*bytes.Buffer, string, error)
- func StructToMultipartPipe(s any) (io.ReadCloser, string, error)
- func StructToMultipartWriter(writer *multipart.Writer, s any) error
- func StructToUrlValues(s any) url.Values
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeBytes ¶
func ParseResponse ¶
ParseResponse parses the HTTP response and returns the decoded value of type T. It checks http.Response.StatusCode, decodes and checks if the http.Response.Body decodes into types.ErrorResponse, and finally decodes into T if no errors are returned. ParseResponse also calls io.Closer.Close on the Body.
func StructToMultipartForm ¶
StructToMultipartForm builds a multipart/form-data body from a struct. It returns the body buffer and the content type (with boundary).
func StructToMultipartPipe ¶
func StructToMultipartPipe(s any) (io.ReadCloser, string, error)
StructToMultipartPipe builds a multipart/form-data body from a struct. It returns an io.ReadCloser and the content type (with boundary).
func StructToMultipartWriter ¶
StructToMultipartWriter builds a multipart/form-data body from a struct. It writes to a multipart.Writer directly
func StructToUrlValues ¶
StructToUrlValues converts a struct to url.Values.
Types ¶
This section is empty.