httpx

package
v0.0.0-...-218d4e6 Latest Latest
Warning

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

Go to latest
Published: May 6, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFormValues

func GetFormValues(r *http.Request) (map[string]any, error)

GetFormValues returns the form values.

func GetRemoteAddr

func GetRemoteAddr(r *http.Request) string

GetRemoteAddr returns the peer address, supports X-Forward-For.

func Parse

func Parse(r *http.Request, v any, isValidate bool) error

Parse parses the request.

func ParseAcceptLanguage

func ParseAcceptLanguage(lang string) (string, error)

func ParseForm

func ParseForm(r *http.Request, v any) error

ParseForm parses the form request.

func ParseHeader

func ParseHeader(headerValue string) map[string]string

ParseHeader parses the request header and returns a map.

func ParseHeaders

func ParseHeaders(r *http.Request, v any) error

ParseHeaders parses the headers request.

func ParseJsonBody

func ParseJsonBody(r *http.Request, v any) error

ParseJsonBody parses the post request which contains json in body.

func ParsePath

func ParsePath(r *http.Request, v any) error

ParsePath parses the symbols reside in url path. Like http://localhost/bag/:name

func RegisterValidation

func RegisterValidation(tag string, fn validator.Func)

RegisterValidation registers the validation function to validator

func RegisterValidationTranslation

func RegisterValidationTranslation(tag string, trans ut.Translator, registerFn validator.RegisterTranslationsFunc,
	translationFn validator.TranslationFunc)

RegisterValidationTranslation regiters the validation translation for validator

func SetValidatorErrorCode

func SetValidatorErrorCode(code int)

SetValidatorErrorCode sets the error code for validator when errors occurs

Types

type Validator

type Validator struct {
	Validator *validator.Validate
	Uni       *ut.UniversalTranslator
	Trans     map[string]ut.Translator
	ErrorCode int
}

func NewValidator

func NewValidator() *Validator

func (*Validator) Validate

func (v *Validator) Validate(data any, lang string) string

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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