httputil

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResolveRequestURL

func ResolveRequestURL(r *http.Request) (*url.URL, error)

Types

type Client

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

func NewClient

func NewClient(cache cache.Cache, maxAge time.Duration) *Client

func (*Client) CacheKey

func (c *Client) CacheKey(req *http.Request) string

func (*Client) Collect

func (c *Client) Collect(ch chan<- prometheus.Metric)

Collect implements prometheus.Collector.

func (*Client) Describe

func (c *Client) Describe(descs chan<- *prometheus.Desc)

Describe implements prometheus.Collector.

func (*Client) Do

func (c *Client) Do(req *http.Request) (*http.Response, error)

See http.Client.Do.

func (*Client) DoCached

func (c *Client) DoCached(req *http.Request) (*http.Response, error)

DoCached returns a cached response for the request. If no cache entry exists, http.Client.Do is used. If the request succeeds, its response is cached if the response code is 2xx. It is the caller's responsibility to ensure that caching the request is sensible (i.e. only for GET requests). NOTE: Cached responses for URLs that were redirected will not have the correct request URL for the response - it will be the original request rather than the request to the final resource.

type Link struct {
	URL    *url.URL
	Params map[string]string
}

func ParseLinkHeader

func ParseLinkHeader(origin *url.URL, header string) ([]Link, error)

ParseLinkHeader parses a Link header.

SEE: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Link.

Jump to

Keyboard shortcuts

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