Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Encoder ¶
type Encoder func() Encoding
Encoder is a function returns Encoding interface for Qsign to encode digest.
type Encoding ¶
type Encoding interface { // Encode encodes src using the encoding enc, writing EncodedLen(len(src)) bytes to dst. Encode(dst, src []byte) // EncodedLen returns the length in bytes of the encoding scheme of an input buffer of length n. EncodedLen(n int) int }
Encoding is an interface for various encoding scheme.
type Filter ¶
Filter is function receives a key-value pair, returns bool value. It's used to filter out invalid key-value pair in the digest.
type Generator ¶
type Generator func() string
Generator is function returns string. It's used to generate digest prefix or suffix.
type Hasher ¶
Hasher is function returns hash.Hash. By default, Qsign uses md5 hash. You can provide your own hash interface instead.
type Options ¶
type Options struct { PrefixGenerator Generator SuffixGenerator Generator Encoder Encoder Filter Filter Hasher Hasher }
Options is optional attributes for building NewSign function to build *Qsign.
PrefixGenerator and SuffixGenerator is two functions which you can use to generating prefix string prepending to digest and suffix string appending to digest string.
Filter is a function used to get rid of some keys or values. For example you want a field which its value is empty being ignored. And this is the default filter.
Encoder is a function which returns Encoding interface. By default it returns hex encoding. If you want to use base64 encoding, you can give a function which returns base64.StdEncoding.
Hasher is a function which returns hash.Hash. By default it returns the Hash from crypto/md5.
type Qsign ¶
type Qsign struct {
// contains filtered or unexported fields
}
Qsign is the signer which signs structs.
func (*Qsign) Digest ¶
Digest generates digest bytes for interface v. By default, it parses struct v, gets all the keys and values, and connects them like an HTTP query string.
Key's value is struct field name if there is no tags like "qsign", "json", "yaml" or "xml". If any key has a tag mentioned before, it will get value from the tag for that key. Tag name "qsign" has the highest priority. Field tag valuewith "-" will be ignored.
All the values expect for Array, Slice and Struct type will be parsed to string. There is an exception here, if the struct has a String method (`func String() string`), it will be parsed.
func (*Qsign) SetConnector ¶
SetConnector changes the default connector.
func (*Qsign) SetDelimiter ¶
SetDelimiter changes the default delimiter.