torequtil

package
v7.0.0-rc2+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2022 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 1 more Imports: 11 Imported by: 0

Documentation

Overview

torequtil has utility functions used by toreq and toreqnew which don't require the Traffic Ops client, and thus can be shared.

Index

Constants

View Source
const CookieCacheDir = `/var/lib/trafficcontrol-cache-config/`

Variables

This section is empty.

Functions

func CookieCacheFileName

func CookieCacheFileName(userName string) string

func CookieCachePath

func CookieCachePath(userName string) string

func CookiesToString

func CookiesToString(cookies []*http.Cookie) string

func GetRetry

func GetRetry(numRetries int, objName string, obj interface{}, getter func(obj interface{}) error) error

GetRetry attempts to get the given object, retrying with exponential backoff up to cfg.NumRetries. The objName is not used in actual fetching or logic, but only for logging. It can be any printable string, but should be unique and reflect the object being fetched.

func GetTOToolNameAndURL

func GetTOToolNameAndURL(globalParams []tc.Parameter) (string, string)

func MaybeHdrStr

func MaybeHdrStr(hdr http.Header, hdrName string) string

MaybeHdrStr returns the header text if hdr isn't nil, or the empty string if it is. This is intended for logging, to allow logging with one line, whether a header object is nil or not.

The hdrName must be the canonically-capitalized header name.

func MaybeIPStr

func MaybeIPStr(addr net.Addr) string

MaybeIPStr returns the addr string if it isn't nil, or the empty string if it is. This is intended for logging, to allow logging with one line, whether addr is nil or not.

func RetryBackoffSeconds

func RetryBackoffSeconds(currentRetry int) int

func StringToCookies

func StringToCookies(cookiesStr string) []*http.Cookie

Types

type Cookie struct {
	Cookie *http.Cookie `json:"cookie"`
}

type FsCookie

type FsCookie struct {
	Cookies []Cookie `json:"cookies"`
}

func GetFsCookie

func GetFsCookie(cookiePath string) (FsCookie, error)

func (*FsCookie) GetHTTPCookies

func (fc *FsCookie) GetHTTPCookies() []*http.Cookie

Jump to

Keyboard shortcuts

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