utils

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2022 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodePath added in v0.0.2

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 added in v0.0.2

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 added in v0.0.2

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

GetSignature final signature in hexadecimal form.

func GetSignedHeaders added in v0.0.2

func GetSignedHeaders(signedHeaders http.Header) string

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

func GetSigningKey added in v0.0.2

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

GetSigningKey hmac seed to calculate final signature.

func GetStringToSign added in v0.0.2

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 added in v0.0.2

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

MustNewSignedV4Request NewSignedV4Request

func NewMockPoolClient added in v0.0.2

func NewMockPoolClient(t *testing.T) (client.PoolClient, func())

func NewRequest added in v0.0.2

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 SignRequestV4 added in v0.0.2

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

SignRequestV4 Sign given request using Signature V4.

func TmpDirPath

func TmpDirPath(t *testing.T) string

func XmlDecoder

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

XmlDecoder provide decoded value in xml.

Types

type ServiceType added in v0.0.2

type ServiceType string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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