Documentation ¶
Overview ¶
Package util provides utilities and constants used throughout the package.
Index ¶
- Constants
- func FormatDate(t time.Time) string
- func FormatDateTime(t time.Time) string
- func GetHost(req *http.Request) string
- func GetURLPath(u *url.URL) string
- func HMACSHA256(key []byte, data []byte) []byte
- func ParseDate(s string) (time.Time, error)
- func ParseDateTime(s string) (time.Time, error)
- func SanitizeHost(req *http.Request)
- func TrimAll(s string) string
Constants ¶
const ( // Algorithm represents the algorithm and version used for signatures. Algorithm = "AWS4-HMAC-SHA256" // TimeFormatISO8601DateTime represents the Go time format for an ISO 8601 date time string. TimeFormatISO8601DateTime = "20060102T150405Z" // TimeFormatISO8601DateTime represents the Go time format for an ISO 8601 date string. TimeFormatISO8601Date = "20060102" // RequestTypeAWS4 represents the type of requests signed by the Signer. RequestTypeAWS4 = "aws4_request" // HashUnsignedPayload represents a predefined hash for an unsigned payload. HashUnsignedPayload = "UNSIGNED-PAYLOAD" // HashEmptyPayload represents the SHA256 hash of an empty payload (an empty string). HashEmptyPayload = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" )
Variables ¶
This section is empty.
Functions ¶
func FormatDate ¶
FormatDate formats the given time using the ISO 8601 date format.
func FormatDateTime ¶
FormatDateTime formats the given time using the ISO 8601 date time format.
func GetHost ¶
GetHost returns the host for the request, preferring the req.Host value if set, falling back to the host of the URL if defined.
func GetURLPath ¶
GetURLPath returns the path for a given URL, preferring the url.Opaque value if defined, falling back to the value of url.EscapedPath().
If defined, url.Opaque must be in the form of:
"//<hostname>/<path>"
func HMACSHA256 ¶
HMACSHA256 creates a HMAC-SHA256 signature of the given data using the provided key, ignoring any errors returned for caller's convenience and easier chaining.
func ParseDateTime ¶
ParseDateTime parses the provided string using the ISO 8601 date time format.
func SanitizeHost ¶
SanitizeHost sanitizes the host of the request, removing the port if it is the default one for the request's scheme.
Types ¶
This section is empty.