util

package
v0.0.0-...-0d805c2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 10, 2020 License: BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateBotPermissionsValue

func CalculateBotPermissionsValue(perms []int) int

CalculateBotPermissionsValue calculates the bot permission value for a given set of permissions.

func DispatchClosedContextError

func DispatchClosedContextError(err error) error

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

func DispatchDuplicateKeyError(err error, msg string) error

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

func IntersectingSlices(a, b []string) bool

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL