httprequest

package
v1.4.15 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: Apache-2.0 Imports: 14 Imported by: 2

Documentation

Index

Constants

View Source
const (
	ContentTypeJson           = "application/json"
	ContentTypeTextXml        = "text/xml"
	ContentTypeApplicationXml = "application/xml"
	ContentTypeText           = "text/"
	ContentTypeBinary         = "application/octet-stream"
	ContentTypeFormData       = "multipart/form-data"
	ContentTypeUrlEncoded     = "application/x-www-form-urlencoded"
)

Variables

This section is empty.

Functions

func Body added in v1.4.11

func Body(v any, r *http.Request, accept ...string) error

Body reads the body of an HTTP request and decodes it into v. You can include the mimetypes that are acceptable, otherwise it will read the body based on the content type. If does not close the body of the request, which should be done by the caller. v can be a io.Writer, in which case the body is copied into it. v can be a struct, in which case the body is decoded into it.

func Query added in v1.4.11

func Query(v any, req url.Values) error

Query copies the query parameters from a request into a structure, which should be a pointer to a struct. The struct should have json tags. No attempt is made to validate the query parameters beyond the conversion from string or []string into the appropriate type. It can use the MarshalJSON interface to convert a string into a custom type.

Types

type Unmarshaller added in v1.4.11

type Unmarshaller interface {
	// Convert a string into a custom type
	UnmarshalJSON([]byte) error
}

Jump to

Keyboard shortcuts

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