Documentation ¶
Index ¶
- Constants
- Variables
- func Canonicalize(req *http.Request) (out string, err error)
- func CanonicalizeS3(req *http.Request) (out string, err error)
- func CodeToError(i int) (err error)
- func NewRequest(url_ *url.URL, method string, hdrs http.Header, params url.Values) (req *http.Request)
- func SortedEscape(v url.Values) (out string)
- func URLDialer(u *url.URL, conf *tls.Config) (f func() (c net.Conn, err error))
- type Conn
- type Dialer
- type ReusableConn
- func (self *ReusableConn) Close() (err error)
- func (self *ReusableConn) Dial() (err error)
- func (self *ReusableConn) LocalAddr() (a net.Addr)
- func (self *ReusableConn) Read(in []byte) (n int, err error)
- func (self *ReusableConn) RemoteAddr() (a net.Addr)
- func (self *ReusableConn) SetDeadline(t time.Time) (err error)
- func (self *ReusableConn) SetReadDeadline(t time.Time) (err error)
- func (self *ReusableConn) SetWriteDeadline(t time.Time) (err error)
- func (self *ReusableConn) Write(out []byte) (n int, err error)
- type Signer
- func (self *Signer) SignBytes(h crypto.Hash, buff []byte) (sig []byte, err error)
- func (self *Signer) SignEncoded(h crypto.Hash, s string, e *base64.Encoding) (out []byte, err error)
- func (self *Signer) SignRequestV1(req *http.Request, canon func(*http.Request) (string, error), exp int64) (err error)
- func (self *Signer) SignRequestV2(req *http.Request, canon func(*http.Request) (string, error), api_ver string, ...) (err error)
- func (self *Signer) SignString(h crypto.Hash, s string) (os string, err error)
Constants ¶
const ( DEFAULT_SIGNATURE_VERSION = "2" DEFAULT_SIGNATURE_METHOD = "HmacSHA256" )
Variables ¶
var ErrUnderlyingNotconnected = errors.New("Underlying socket is not connected")
var ErrorConflicts = errors.New("Conflicts with another resources")
var ErrorForbidden = errors.New("Access denied")
var ErrorNotFound = errors.New("Not found")
var ErrorUnexpectedResponse = errors.New("Unexpected response code")
var ISO8601TimestampFormat = "2006-01-02T15:04:05Z"
var SQSTimestampFormat = "2006-01-02T15:04:05MST"
Functions ¶
func Canonicalize ¶
Generates the canonical string-to-sign for (most) AWS services. You shouldn't need to use this directly.
func CanonicalizeS3 ¶
Generates the canonical string-to-sign for S3 services. You shouldn't need to use this directly unless you're pre-signing URL's.
func CodeToError ¶
func NewRequest ¶
func NewRequest(url_ *url.URL, method string, hdrs http.Header, params url.Values) (req *http.Request)
Constructs a basic http.Request based off of a fully-qualified URL
func SortedEscape ¶
(2011-06-21) - The standard go http.Values.Escape works properly for SQS and S3, but it should be noted that at least SDB requiers more to be escaped than is officially standard.
Sorted Escape also sorts the keys before joining them (needed for canonicalization).
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
The conn structure represents a 'semi detached' http-client It handles redialing & reconnecting on connection errors.
type Dialer ¶
A Dialer is usually a closuer that is pre-configured to the callers tastes.
(see URLDialer for an example/default generator)
type ReusableConn ¶
type ReusableConn struct {
// contains filtered or unexported fields
}
A Reusable conn is a syncronized structure around a Dialer / net.Conn pair. All net.Conn calls are wrapped around the underlying structure. Errors are bubbled up, and trigger closure of the underlying socket (to be reopened on the next call)
func NewReusableConnection ¶
func NewReusableConnection(d Dialer) (c *ReusableConn)
Create a new reusable connection with a sepcific dialer.
func (*ReusableConn) Close ¶
func (self *ReusableConn) Close() (err error)
Unlike close on a traditional socket, no error is raised if you close a closed (nil) connection.
func (*ReusableConn) Dial ¶
func (self *ReusableConn) Dial() (err error)
Dial is idempotent, and safe to call;
func (*ReusableConn) LocalAddr ¶
func (self *ReusableConn) LocalAddr() (a net.Addr)
See RemoteAddr for notes.
func (*ReusableConn) Read ¶
func (self *ReusableConn) Read(in []byte) (n int, err error)
Read from the underlying connection, triggering a dial if needed. NB: For the expected case (HTTP), this shouldn't happen before the first Write.
func (*ReusableConn) RemoteAddr ¶
func (self *ReusableConn) RemoteAddr() (a net.Addr)
TODO: What's an appropriate responsde when we're not connected? ATM, we return whatever the other side says, or the nil net.Addr.
func (*ReusableConn) SetDeadline ¶
func (self *ReusableConn) SetDeadline(t time.Time) (err error)
Convenience function for Set(Read|Write)Deadline
func (*ReusableConn) SetReadDeadline ¶
func (self *ReusableConn) SetReadDeadline(t time.Time) (err error)
Sets the read deadline on the underlying socket, as well as an internal flag for any future re-opened connections.
func (*ReusableConn) SetWriteDeadline ¶
func (self *ReusableConn) SetWriteDeadline(t time.Time) (err error)
Sets the write deadline on the underlying socket, as well as an internal flag for any future re-opened connections.
type Signer ¶
type Signer struct { AccessKey string // contains filtered or unexported fields }
A signer simply holds the access & secret access keys necessary for aws, and proivides helper functions to assist in generating an appropriate signature.
func (*Signer) SignEncoded ¶
func (self *Signer) SignEncoded(h crypto.Hash, s string, e *base64.Encoding) (out []byte, err error)
SignBytes, but will base64 encode based on the specified encoder.
func (*Signer) SignRequestV1 ¶
func (self *Signer) SignRequestV1(req *http.Request, canon func(*http.Request) (string, error), exp int64) (err error)
Used exclusively by S3 to the best of my knowledge...
func (*Signer) SignRequestV2 ¶
func (self *Signer) SignRequestV2(req *http.Request, canon func(*http.Request) (string, error), api_ver string, exp int64) (err error)
The V2 denotes amazon signing version 2, not version 2 of this particular function... V2 is used by all services but S3; Note, some services vary in their exact implementation of escaping w/r/t signatures, so it is recommended you use this function.
Final note: if exp is set to 0, a Timestamp will be used, otherwise an expiration.