httpu

package
v0.13.5 Latest Latest
Warning

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

Go to latest
Published: May 10, 2026 License: MIT Imports: 14 Imported by: 4

Documentation

Index

Constants

View Source
const (
	HeaderContentType       = "Content-Type"
	HeaderContentLength     = "Content-Length"
	HeaderAcceptRanges      = "Accept-Ranges"
	HeaderAuthorization     = "Authorization"
	HeaderDate              = "Date"
	HeaderContentEncoding   = "Content-Encoding"
	HeaderContentLanguage   = "Content-Language"
	HeaderContentMD5        = "Content-MD5"
	HeaderIfModifiedSince   = "If-Modified-Since"
	HeaderIfMatch           = "If-Match"
	HeaderIfNoneMatch       = "If-None-Match"
	HeaderIfUnmodifiedSince = "If-Unmodified-Since"
	HeaderRange             = "Range"
	HeaderTransferEncoding  = "Transfer-Encoding"
	HeaderServer            = "Server"
	HeaderUserAgent         = "User-Agent"
	HeaderAccept            = "Accept"

	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 GetRealRemoteIP added in v0.11.30

func GetRealRemoteIP(r *http.Request) string

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 RespAny added in v0.13.0

func RespAny(w http.ResponseWriter, statusCode int, a any, headersKV ...string)

func RespBytes added in v0.13.0

func RespBytes(w http.ResponseWriter, statusCode int, bs []byte, 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 RespJSON

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

func RespReader added in v0.10.0

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

func RespString added in v0.13.0

func RespString(w http.ResponseWriter, statusCode int, str string, headersKV ...string)

func RespYAML added in v0.13.0

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

Types

type Decoder added in v0.10.4

type Decoder interface {
	Decode(v any) error
}

type Encoder added in v0.10.0

type Encoder interface {
	Encode(v any) error
}

type NewDecoder added in v0.10.4

type NewDecoder func(r io.Reader) Decoder

type NewEncoder added in v0.10.0

type NewEncoder func(w io.Writer) Encoder

type RecordResponseWriter added in v0.13.0

type RecordResponseWriter struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

func NewRecordResponseWriter added in v0.13.0

func NewRecordResponseWriter(w http.ResponseWriter) *RecordResponseWriter

func (*RecordResponseWriter) Flush added in v0.13.0

func (rp *RecordResponseWriter) Flush()

func (*RecordResponseWriter) Hijack added in v0.13.0

func (rp *RecordResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)

func (*RecordResponseWriter) Size added in v0.13.0

func (rp *RecordResponseWriter) Size() int

func (*RecordResponseWriter) Status added in v0.13.0

func (rp *RecordResponseWriter) Status() int

func (*RecordResponseWriter) Write added in v0.13.0

func (rp *RecordResponseWriter) Write(data []byte) (int, error)

func (*RecordResponseWriter) WriteHeader added in v0.13.0

func (rp *RecordResponseWriter) WriteHeader(statusCode int)

func (*RecordResponseWriter) Written added in v0.13.0

func (rp *RecordResponseWriter) Written() bool

Jump to

Keyboard shortcuts

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