request

package
v0.0.0-...-d3cc92b Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const FeedbackPkg = feedback.Package("request")

Variables

This section is empty.

Functions

func BaseURL

func BaseURL(protocol string, trimmedURL string, a ...any) string

BaseURL prepends `protocol + "://"` or `protocol + "s://"` to the url depending on TLS support.

func Fetch

func Fetch(url, method string, cacheMaxAge time.Duration, timeout time.Duration, reportProgress bool, body io.Reader) (responseBody io.ReadCloser, statusCode int, err error)

func FetchFile

func FetchFile(url string, cacheMaxAge time.Duration, reportProgress bool) (io.ReadCloser, error)

func FetchJSON

func FetchJSON[T any](url string, maxCacheAge time.Duration) (T, error)

func HasContentType

func HasContentType(h http.Header, mimetype string) bool

HasContentType returns true if the 'content-type' header includes mimetype.

func IsTLS

func IsTLS(trimmedURL string) (isTLS bool)

IsTLS verifies the TLS certificate of a trimmed URL.

func PostJSON

func PostJSON[T any](url string, data any) (T, error)

func TrimURL

func TrimURL(url string) string

TrimURL removes the protocol component and trailing slashes.

Types

This section is empty.

Jump to

Keyboard shortcuts

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