util

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: Apache-2.0 Imports: 17 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBaseURL

func GetBaseURL(r *http.Request, s string) (string, string)

GetBaseURL returns base path based on some match.

func GetContentType

func GetContentType(r *http.Request) string

GetContentType returns requested content type.

func GetCurrentBaseURL

func GetCurrentBaseURL(r *http.Request) string

GetCurrentBaseURL returns current base URL.

func GetCurrentURL

func GetCurrentURL(r *http.Request) string

GetCurrentURL returns current URL.

func GetIssuerURL

func GetIssuerURL(r *http.Request) string

GetIssuerURL returns issuer URL.

func GetRandomEncodedStringFromRange

func GetRandomEncodedStringFromRange(a, b int) string

GetRandomEncodedStringFromRange return the number returned by GetRandomStringFromRange() and encoded with Base32

func GetRandomString

func GetRandomString(i int) string

GetRandomString returns X character long random string.

func GetRandomStringFromRange

func GetRandomStringFromRange(a, b int) string

GetRandomStringFromRange generates random string of a random length. The random lenght is bounded by a and b.

func GetRandomStringFromRangeWithCharset

func GetRandomStringFromRangeWithCharset(a, b int, cs string) string

GetRandomStringFromRangeWithCharset generates random string of a random length. The random lenght is bounded by a and b. The charset is provided.

func GetRelativeURL

func GetRelativeURL(r *http.Request, orig, repl string) string

GetRelativeURL returns relative path to current URL.

func GetRequestID

func GetRequestID(r *http.Request) string

GetRequestID returns request ID.

func IsMalformedRandomString added in v1.0.23

func IsMalformedRandomString(s string, a, b int) bool

IsMalformedRandomString checks whether the provided string was generated by the GetRandomStringFromRange() function.

func ParseCredentials

func ParseCredentials(r *http.Request) (map[string]string, error)

ParseCredentials extracts credentials from HTTP request.

func ParseIdentity

func ParseIdentity(r *http.Request) (map[string]string, error)

ParseIdentity extracts user id/email and optional authentication realm from HTTP request.

func SanitizeSessionID added in v1.0.23

func SanitizeSessionID(s string) string

SanitizeSessionID sanitizes provided Session ID.

func SanitizeURL added in v1.0.27

func SanitizeURL(s string) string

SanitizeURL escapes some invalid characters than can allow for Cross Site Scripting

func StripQueryParam

func StripQueryParam(url string, param string) string

StripQueryParam removes a specific query parameter from a URL.

Types

type Browser added in v1.0.17

type Browser struct {
	// contains filtered or unexported fields
}

Browser represents a browser instance.

func NewBrowser added in v1.0.17

func NewBrowser() (*Browser, error)

NewBrowser returns an instance of a browser.

func (*Browser) Do added in v1.0.17

func (b *Browser) Do(req *http.Request) (string, *http.Response, error)

Do makes HTTP requests and parses responses.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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