Documentation ¶
Overview ¶
Package aws4 signs HTTP requests as prescribed in http://docs.amazonwebservices.com/general/latest/gr/signature-version-4.html
Example (FormEncodedBody) ¶
package main import ( "fmt" "github.com/bmizerany/aws4" "log" "net/url" ) func main() { v := make(url.Values) v.Set("Action", "DescribeAutoScalingGroups") resp, err := aws4.PostForm("https://autoscaling.us-east-1.amazonaws.com/", v) if err != nil { log.Fatal(err) } fmt.Println(resp.StatusCode) }
Output: 200
Example (JSONBody) ¶
package main import ( "fmt" "github.com/bmizerany/aws4" "log" "net/http" "strings" ) func main() { data := strings.NewReader("{}") r, _ := http.NewRequest("POST", "https://dynamodb.us-east-1.amazonaws.com/", data) r.Header.Set("Content-Type", "application/x-amz-json-1.0") r.Header.Set("X-Amz-Target", "DynamoDB_20111205.ListTables") resp, err := aws4.DefaultClient.Do(r) if err != nil { log.Fatal(err) } fmt.Println(resp.StatusCode) }
Output: 200
Index ¶
- Variables
- func Post(url string, bodyType string, body io.Reader) (resp *http.Response, err error)
- func PostForm(url string, data url.Values) (resp *http.Response, err error)
- func Sign(keys *Keys, r *http.Request) error
- type Client
- func (c *Client) Do(req *http.Request) (resp *http.Response, err error)
- func (c *Client) Get(url string) (resp *http.Response, err error)
- func (c *Client) Head(url string) (resp *http.Response, err error)
- func (c *Client) Post(url string, bodyType string, body io.Reader) (resp *http.Response, err error)
- func (c *Client) PostForm(url string, data url.Values) (resp *http.Response, err error)
- type Keys
- type Service
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultClient = &Client{Keys: KeysFromEnvironment()}
Functions ¶
Types ¶
type Client ¶
type Client struct { Keys *Keys // The http client to make requests with. If nil, http.DefaultClient is used. Client *http.Client }
Client is like http.Client, but signs all requests using Keys.
type Keys ¶
Keys holds a set of Amazon Security Credentials.
func KeysFromEnvironment ¶
func KeysFromEnvironment() *Keys
Initializes and returns a Keys using the AWS_ACCESS_KEY and AWS_SECRET_KEY environment variables.
Click to show internal directories.
Click to hide internal directories.