httputil

package
v1.130.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2025 License: Apache-2.0 Imports: 9 Imported by: 16

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckURL

func CheckURL(urlStr string) error

CheckURL checks whether urlStr contains valid URL.

func GetArray

func GetArray(r *http.Request, argKey, headerKey string) []string

GetArray returns an array of comma-separated values from r with the argKey quey arg or with headerKey header.

func GetBool

func GetBool(r *http.Request, argKey string) bool

GetBool returns boolean value from the given argKey query arg.

func GetDuration

func GetDuration(r *http.Request, argKey string, defaultValue int64) (int64, error)

GetDuration returns duration in milliseconds from the given argKey query arg.

func GetInt

func GetInt(r *http.Request, argKey string) (int, error)

GetInt returns integer value from the given argKey.

func GetRequestValue

func GetRequestValue(r *http.Request, argKey, headerKey string) string

GetRequestValue returns r value for the given argKey query arg or for the given headerKey header.

func GetTime

func GetTime(r *http.Request, argKey string, defaultMs int64) (int64, error)

GetTime returns time in milliseconds from the given argKey query arg.

If argKey is missing in r, then defaultMs rounded to seconds is returned. The rounding is needed in order to align query results in Grafana executed at different times. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/720

func NewTransport

func NewTransport(enableHTTP2 bool, metricsPrefix string) *http.Transport

NewTransport returns pre-initialized http.Transport with sane defaults.

Data transfer for the returned transport is tracked with metrics, which are exposed with the given metricsPrefix.

It is OK to change settings of the returned transport before its' usage.

If enableHTTP2 is set, then the returned transport is ready for http2 requests.

It is recommended disabling http2 support, since it is too bloated, slow and contains many security breaches. See https://www.google.com/search?q=http2+security+issues . Also, http2 doesn't bring any advantages over http/1.1 when communicating with server backends.

Types

This section is empty.

Jump to

Keyboard shortcuts

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