sign

package module
v0.0.0-...-b684218 Latest Latest
Warning

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

Go to latest
Published: May 21, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

README

Golang package for signing Aliyun API gateway requests

Same algorithm as the following 'official' demos in other language.

Compliance is not fully guaranteed, since I have not found the official documentation on this algorithm. Use at your own risk.

Installation

go get -u github.com/HuanTeng/go-aliyun-sign

Usage

import "github.com/HuanTeng/go-aliyun-sign"

// Prepare a Request
req, _ := http.NewRequest("POST", url, body)
// Set headers
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Accept", "application/json")
// Sign the request
if err := sign.Sign(req, appKey, appSecret); err != nil {
    // Handle error
}
// Do the request round-trip
resp, err := http.DefaultClient.Do(req)

Documentation

Index

Constants

View Source
const (
	HTTPHeaderAccept      = "Accept"
	HTTPHeaderContentMD5  = "Content-MD5"
	HTTPHeaderContentType = "Content-Type"
	HTTPHeaderUserAgent   = "User-Agent"
	HTTPHeaderDate        = "Date"
)

HTTP Header keys

View Source
const (
	HTTPHeaderCAPrefix           = "X-Ca-"
	HTTPHeaderCASignature        = "X-Ca-Signature"
	HTTPHeaderCATimestamp        = "X-Ca-Timestamp"
	HTTPHeaderCANonce            = "X-Ca-Nonce"
	HTTPHeaderCAKey              = "X-Ca-Key"
	HTTPHeaderCASignatureHeaders = "X-Ca-Signature-Headers"
)

HTTP Header keys used for aliyun signature

Variables

This section is empty.

Functions

func Sign

func Sign(req *http.Request, appKey, appSecret string) error

Sign a request with application credentials (appKey, appSecret)

Types

This section is empty.

Jump to

Keyboard shortcuts

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