util

package
v0.0.0-...-dc04344 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2019 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainedIn

func ContainedIn(value string, list []string) bool

util.ContainedIn checks if a value in a list of a strings

func ContainsSubString

func ContainsSubString(value string, list []string) bool

ContainsSubString checks if substring exists

func DecodeKeyPairs

func DecodeKeyPairs(list []string) (map[string]string, error)

DecodeKeyPairs converts a list of strings (key=pair) to a map

func DecodeText

func DecodeText(state, key string) (string, error)

DecodeText decodes the session state cookie value

func DefaultTo

func DefaultTo(v, d string) string

DefaultTo returns the value of the default

func EncodeText

func EncodeText(plaintext string, key string) (string, error)

EncodeText encodes the session state information into a value for a cookie to consume

func FileExists

func FileExists(filename string) bool

fileExists check if a file exists

func FindCookie

func FindCookie(name string, cookies []*http.Cookie) *http.Cookie

FindCookie looks for a cookie in a list of cookies

func GetHashKey

func GetHashKey(token *jose.JWT) string

GetHashKey returns a hash of the encodes jwt token

func GetRequestHostURL

func GetRequestHostURL(r *http.Request) string

GetRequestHostURL returns the hostname from the request

func GetWithin

func GetWithin(expires time.Time, within float64) time.Duration

GetWithin calculates a duration of x percent of the time period, i.e. something expires in 1 hours, get me a duration within 80%

func HasAccess

func HasAccess(need, have []string, all bool) bool

HasAccess checks we have all or any of the needed items in the list

func IsUpgradedConnection

func IsUpgradedConnection(req *http.Request) bool

IsUpgradedConnection checks to see if the request is requesting

func IsValidHTTPMethod

func IsValidHTTPMethod(method string) bool

IsValidHTTPMethod ensure this is a valid http method type

func LoadCA

func LoadCA(cert, key string) (*tls.Certificate, error)

LoadCA loads the certificate authority

func MergeMaps

func MergeMaps(dest, source map[string]string) map[string]string

MergeMaps simples copies the keys from source to destination

func PrintError

func PrintError(message string, args ...interface{}) *cli.ExitError

printError display the command line usage and error

func RealIP

func RealIP(req *http.Request) string

RealIP retrieves the client ip address from a http request

func ToHeader

func ToHeader(v string) string

ToHeader is a helper method to play nice in the headers

func TryUpdateConnection

func TryUpdateConnection(req *http.Request, writer http.ResponseWriter, endpoint *url.URL) error

TryUpdateConnection attempt to upgrade the connection to a http pdy stream

Types

This section is empty.

Jump to

Keyboard shortcuts

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