utils

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2022 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BgContext

func BgContext(parent context.Context) context.Context

BgContext returns a context that can be used for async operations. Cancellation/timeouts are removed, so parent cancellations/timeout will not propagate from parent. Context values are preserved. This can be used for goroutines that live beyond the parent context.

func CloneMapSS

func CloneMapSS(src map[string]string) map[string]string

func EncodePath

func EncodePath(pathName string) string

EncodePath encode the strings from UTF-8 byte representations to HTML hex escape sequences

This is necessary since regular url.Parse() and url.Encode() functions do not support UTF-8 non english characters cannot be parsed due to the nature in which url.Encode() is written

This function on the other hand is a direct replacement for url.Encode() technique to support pretty much every UTF-8 character.

func GetCanonicalRequest

func GetCanonicalRequest(extractedSignedHeaders http.Header, payload, queryStr, urlPath, method string) string

GetCanonicalRequest generate a canonical request of style

canonicalRequest =

<HTTPMethod>\n
<CanonicalURI>\n
<CanonicalQueryString>\n
<CanonicalHeaders>\n
<SignedHeaders>\n
<HashedPayload>

func GetSignature

func GetSignature(signingKey []byte, stringToSign string) string

GetSignature final signature in hexadecimal form.

func GetSignedHeaders

func GetSignedHeaders(signedHeaders http.Header) string

GetSignedHeaders generate a string i.e alphabetically sorted, semicolon-separated list of lowercase request header names

func GetSigningKey

func GetSigningKey(secretKey string, t time.Time, region string, serviceType string) []byte

GetSigningKey hmac seed to calculate final signature.

func GetStringToSign

func GetStringToSign(canonicalRequest string, t time.Time, scope string) string

GetStringToSign a string based on selected query values.

func MustGetLocalIP4

func MustGetLocalIP4() (ipList set.StringSet)

MustGetLocalIP4 returns IPv4 addresses of localhost. It panics on error.

func MustNewSignedV4Request

func MustNewSignedV4Request(method string, urlStr string, contentLength int64, body io.ReadSeeker, st ServiceType, accessKey, secretKey string, t *testing.T) *http.Request

MustNewSignedV4Request NewSignedV4Request

func NewRequest

func NewRequest(method, urlStr string, contentLength int64, body io.ReadSeeker) (*http.Request, error)

NewRequest Returns new HTTP request object.

func S3EncodeName

func S3EncodeName(name string, encodingType string) (result string)

S3EncodeName encodes string in response when encodingType is specified in AWS S3 requests.

func SetupLogLevels

func SetupLogLevels()

func SignRequestV4

func SignRequestV4(req *http.Request, accessKey, secretKey string, st ServiceType) error

SignRequestV4 Sign given request using Signature V4.

func XmlDecoder

func XmlDecoder(body io.Reader, v interface{}, size int64) error

XmlDecoder provide decoded value in xml.

Types

type ServiceType

type ServiceType string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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