httpu

package
v0.10.3 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2025 License: MIT Imports: 10 Imported by: 3

Documentation

Index

Constants

View Source
const (
	HeaderContentType   = "Content-Type"
	HeaderContentLength = "Content-Length"

	MIMEHTML              = "text/html"
	MIMEHTMLUTF8          = "text/html; charset=utf-8"
	MIMEJSON              = "application/json"
	MIMEJSONUTF8          = "application/json; charset=utf-8"
	MIMEXML               = "application/xml"
	MIMEXML2              = "text/xml"
	MIMEPlain             = "text/plain"
	MIMEPlainUTF8         = "text/plain; charset=utf-8"
	MIMEPOSTForm          = "application/x-www-form-urlencoded"
	MIMEMultipartPOSTForm = "multipart/form-data"
	MIMEPROTOBUF          = "application/x-protobuf"
	MIMEMSGPACK           = "application/x-msgpack"
	MIMEMSGPACK2          = "application/msgpack"
	MIMEYAML              = "application/x-yaml"
	MIMEYAML2             = "application/yaml"
	MIMETOML              = "application/toml"
)

Variables

This section is empty.

Functions

func ReqTo added in v0.10.0

func ReqTo(r *http.Request, obj any) error

func ReqToJSON added in v0.7.0

func ReqToJSON(r *http.Request, obj any) error

func ReqToPB added in v0.7.0

func ReqToPB(r *http.Request, obj any) error

func ReqToTOML added in v0.7.0

func ReqToTOML(r *http.Request, obj any) error

func ReqToXML added in v0.7.0

func ReqToXML(r *http.Request, obj any) error

func ReqToYAML added in v0.7.0

func ReqToYAML(r *http.Request, obj any) error

func Resp

func Resp(w http.ResponseWriter, statusCode int, data any, headersKV ...string)

func RespEncoder added in v0.10.0

func RespEncoder(w http.ResponseWriter, statusCode int, data any, mime string, newEncoder NewEncoder, headersKV ...string)

func RespFail

func RespFail(data any, w http.ResponseWriter, headersKV ...string)

func RespJSON

func RespJSON(w http.ResponseWriter, statusCode int, data any, headersKV ...string)

func RespJSONFail

func RespJSONFail(w http.ResponseWriter, data any, headersKV ...string)

func RespJSONOk

func RespJSONOk(w http.ResponseWriter, data any, headersKV ...string)

func RespOk

func RespOk(data any, w http.ResponseWriter, headersKV ...string)

func RespRaw

func RespRaw(w http.ResponseWriter, statusCode int, data []byte, headersKV ...string)

func RespRawFail

func RespRawFail(data []byte, w http.ResponseWriter, headersKV ...string)

func RespRawOk

func RespRawOk(data []byte, w http.ResponseWriter, headersKV ...string)

func RespReader added in v0.10.0

func RespReader(w http.ResponseWriter, statusCode int, r io.Reader, headersKV ...string)

func RespReaderFail added in v0.10.0

func RespReaderFail(w http.ResponseWriter, r io.Reader, headersKV ...string)

func RespReaderOk added in v0.10.0

func RespReaderOk(w http.ResponseWriter, r io.Reader, headersKV ...string)

Types

type Encoder added in v0.10.0

type Encoder interface {
	Encode(v any) error
}

type NewEncoder added in v0.10.0

type NewEncoder func(w io.Writer) Encoder

Jump to

Keyboard shortcuts

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