http

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MegaByte16 = 16 * 1024 * 1024
)

Variables

View Source
var (
	ErrBind = fmt.Errorf("bind error")
)

Functions

func BindForm

func BindForm(req *http.Request, target interface{}) error

BindForm bind form parameters to target.

func BindRequestBody

func BindRequestBody(r *http.Request, v interface{}, opts ...OptionFunc) error

BindRequestBody decodes the request body to object.

func BindRequestQuery

func BindRequestQuery(r *http.Request, v interface{}) error

BindRequestQuery decodes the request vars to object.

func BindRequestVars

func BindRequestVars(r *http.Request, raws map[string]string, v interface{}) error

BindRequestVars decodes the request vars to object.

func BindURLValues added in v0.0.5

func BindURLValues(vars url.Values, target interface{}) error

BindURLValues bind vars parameters to target.

func CodecForRequest

func CodecForRequest(r *http.Request, name string, opt Options) (encoding.Codec, bool)

CodecForRequest get encoding.Codec via http.Request

func ContentSubtype

func ContentSubtype(contentType string) string

ContentSubtype returns the content-subtype for the given content-type. The given content-type must be a valid content-type that starts with but no content-subtype will be returned. according rfc7231. contentType is assumed to be lowercase already.

func ContentType

func ContentType(subtype string) string

ContentType returns the content-type with base prefix.

func EncodeURL

func EncodeURL(pathTemplate string, msg interface{}, needQuery bool) string

EncodeURL encode proto message to url path.

func TryMyBestBind added in v0.0.2

func TryMyBestBind(r *http.Request, v interface{}, opts ...OptionFunc)

TryMyBestBind decodes the request to object. 不支持解析 multipart/form-data , 需要解析大文件数据请使用 BindForm 只有 MegaByte16 以下的内容才能被 form-data 解析

Types

type OptionFunc

type OptionFunc func(*Options)

func WithDefaultCodec

func WithDefaultCodec(codec string) OptionFunc

WithDefaultCodec set default codec.

type Options

type Options struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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