Documentation ¶
Index ¶
- func CalculateBotPermissionsValue(perms []int) int
- func DispatchClosedContextError(err error) error
- func DispatchDuplicateKeyError(err error, msg string) error
- func HTTPError(w http.ResponseWriter, msg string, code int)
- func IntersectingSlices(a, b []string) bool
- type OAuth2TokenHTTPClientKey
- type OAuth2TokenSessionKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalculateBotPermissionsValue ¶
CalculateBotPermissionsValue calculates the bot permission value for a given set of permissions.
func DispatchClosedContextError ¶
DispatchClosedContextError is meant to be used when the RPC context's Done channel is closed. It returns a Twirp error matching the context error type.
func DispatchDuplicateKeyError ¶
DispatchDuplicateKeyError looks for a MongoDB error caused by an insert that would result in duplicate unique keys. If such error is found, a Twirp AlreadyExists error with given message is returned. Otherwise, a Twirp Internal error is used as a fallback.
func HTTPError ¶
func HTTPError(w http.ResponseWriter, msg string, code int)
HTTPError is a thin wrapper around http.Error method from standard library, which additionally prints given message to stdout.
func IntersectingSlices ¶
IntersectingSlices returns true when two slices have a non-empty intersection. Values in the first slice parameter must be sorted alphabetically.
Types ¶
type OAuth2TokenHTTPClientKey ¶
type OAuth2TokenHTTPClientKey struct{}
OAuth2TokenHTTPClientKey is a key to store a HTTP client that auto-refreshes OAuth 2 token in context.
type OAuth2TokenSessionKey ¶
type OAuth2TokenSessionKey struct{}
OAuth2TokenSessionKey is a key to store a OAuth 2 token session value in context.