Documentation
¶
Index ¶
- Variables
- func Base64Id() *base64Id
- func CheckInvalidHeaderChar(val string) bool
- func CleanPath(p string) string
- func ClearInterval(timer *Timer)
- func ClearTimeout(timer *Timer)
- func Contains(haystack string, needles []string) string
- func Is[T any](val any) bool
- func Log() *log.Log
- func MapValues[K comparable, I any, O any](input map[K]I, transform func(I) O) map[K]O
- func MsgPack() *msgPack
- func NewUtf8Decoder(r io.Reader) io.Reader
- func NewUtf8Encoder(w io.Writer) io.Writer
- func Ptr[T any](v T) *T
- func StripHostPort(h string) string
- func TryCast[T any](val any) T
- func Utf8decodeBytes(src []byte) []byte
- func Utf8decodeString(byteString string) string
- func Utf8encodeBytes(src []byte) []byte
- func Utf8encodeString(src string) string
- func Utf16Count(src []byte) (n int)
- func Utf16CountString(src string) (n int)
- func Utf16Len(v rune) int
- func Value(value string, _default string) string
- func WithFactor(factor float64) backoffOption
- func WithJitter(jitter float64) backoffOption
- func WithMax(max float64) backoffOption
- func WithMin(min float64) backoffOption
- func YeastDate() string
- type Backoff
- type ParameterBag
- func (p *ParameterBag) Add(key string, value string)
- func (p *ParameterBag) All() map[string][]string
- func (p *ParameterBag) Count() int
- func (p *ParameterBag) Get(key string, _default ...string) (string, bool)
- func (p *ParameterBag) GetFirst(key string, _default ...string) (string, bool)
- func (p *ParameterBag) GetLast(key string, _default ...string) (string, bool)
- func (p *ParameterBag) Gets(key string, _default ...[]string) ([]string, bool)
- func (p *ParameterBag) Has(key string) bool
- func (p *ParameterBag) Keys() []string
- func (p *ParameterBag) Peek(key string, _default ...string) string
- func (p *ParameterBag) Remove(key string)
- func (p *ParameterBag) Replace(parameters map[string][]string)
- func (p *ParameterBag) Set(key string, value string)
- func (p *ParameterBag) With(parameters map[string][]string)
- type ParsedUrl
- type Timer
- type Yeast
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultYeast = NewYeast()
Functions ¶
func Base64Id ¶
func Base64Id() *base64Id
Example ¶
_, err := Base64Id().GenerateId() fmt.Println(err)
Output: <nil>
func CheckInvalidHeaderChar ¶
CheckInvalidHeaderChar reports whether v is an invalid "field-value" according to http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2 :
message-header = field-name ":" [ field-value ]
field-value = *( field-content | LWS )
field-content = <the OCTETs making up the field-value
and consisting of either *TEXT or combinations
of token, separators, and quoted-string>
http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2.2 :
TEXT = <any OCTET except CTLs,
but including LWS>
LWS = [CRLF] 1*( SP | HT )
CTL = <any US-ASCII control character
(octets 0 - 31) and DEL (127)>
RFC 7230 says:
field-value = *( field-content / obs-fold ) obj-fold = N/A to http2, and deprecated field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ] field-vchar = VCHAR / obs-text obs-text = %x80-FF VCHAR = "any visible [USASCII] character"
http2 further says: "Similarly, HTTP/2 allows header field values that are not valid. While most of the values that can be encoded will not alter header field parsing, carriage return (CR, ASCII 0xd), line feed (LF, ASCII 0xa), and the zero character (NUL, ASCII 0x0) might be exploited by an attacker if they are translated verbatim. Any request or response that contains a character not permitted in a header field value MUST be treated as malformed (Section 8.1.2.6). Valid characters are defined by the field-content ABNF rule in Section 3.2 of [RFC7230]."
This function does not (yet?) properly handle the rejection of strings that begin or end with SP or HTAB.
func ClearInterval ¶
func ClearInterval(timer *Timer)
func ClearTimeout ¶
func ClearTimeout(timer *Timer)
func MapValues ¶
func MapValues[K comparable, I any, O any](input map[K]I, transform func(I) O) map[K]O
func NewUtf8Encoder ¶
NewEncoder returns an io.Writer that writes lowercase hexadecimal characters to w.
func StripHostPort ¶
func Utf8decodeBytes ¶
func Utf8decodeString ¶
func Utf8encodeBytes ¶
func Utf8encodeString ¶
func Utf16Count ¶
func Utf16CountString ¶
func WithFactor ¶
func WithFactor(factor float64) backoffOption
func WithJitter ¶
func WithJitter(jitter float64) backoffOption
Types ¶
type Backoff ¶
type Backoff struct {
// contains filtered or unexported fields
}
Backoff represents a backoff timer with configurable parameters.
func NewBackoff ¶
func NewBackoff(opts ...backoffOption) *Backoff
NewBackoff creates a new Backoff instance with the given configuration.
type ParameterBag ¶
type ParameterBag struct {
// contains filtered or unexported fields
}
func NewParameterBag ¶
func NewParameterBag(parameters map[string][]string) *ParameterBag
func (*ParameterBag) Add ¶
func (p *ParameterBag) Add(key string, value string)
Add adds the value to key. It appends to any existing values associated with key.
func (*ParameterBag) Get ¶
func (p *ParameterBag) Get(key string, _default ...string) (string, bool)
Returns a parameter by name, defaulting to the last value if present.
func (*ParameterBag) GetFirst ¶
func (p *ParameterBag) GetFirst(key string, _default ...string) (string, bool)
Returns the first value of a parameter by name.
func (*ParameterBag) GetLast ¶
func (p *ParameterBag) GetLast(key string, _default ...string) (string, bool)
Returns the last value of a parameter by name.
func (*ParameterBag) Gets ¶
func (p *ParameterBag) Gets(key string, _default ...[]string) ([]string, bool)
Returns all values of a parameter by name.
func (*ParameterBag) Has ¶
func (p *ParameterBag) Has(key string) bool
Returns true if the parameter is defined.
func (*ParameterBag) Replace ¶
func (p *ParameterBag) Replace(parameters map[string][]string)
Replaces the current parameters by a new set.
func (*ParameterBag) Set ¶
func (p *ParameterBag) Set(key string, value string)
Sets a parameter by name.
func (*ParameterBag) With ¶
func (p *ParameterBag) With(parameters map[string][]string)
Adds or replaces the current parameters with a new set.
type Timer ¶
type Timer struct {
// contains filtered or unexported fields
}