utils

package
v0.0.0-...-26761ab Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EventNotFoundError

func EventNotFoundError(eventKey *string) error

EventNotFoundError constructs a gRPC error to indicate that the provided event key was invalid.

func GenerateAuthCode

func GenerateAuthCode() (uint32, error)

GenerateAuthCode generates a valid, cryptographically random auth code.

func GetAuthTokenFromHeader

func GetAuthTokenFromHeader(ctx context.Context) (string, error)

GetAuthTokenFromHeader parses the auth code out of the request metadata ('authorization' header).

func InsufficientPermissionsError

func InsufficientPermissionsError() error

InsufficientPermissionsError constructs a gRPC error to indicate that the request lacked an authorized token for the requested action. Invalid tokens should use `InvalidAuthError()` instead.

func InvalidArgumentError

func InvalidArgumentError() error

InvalidArgumentError constructs a gRPC error to indicate that the client request was malformed.

func InvalidAuthCodeFormat

func InvalidAuthCodeFormat(authCode uint32) bool

InvalidAuthCodeFormat returns true if the auth code is not a number in the valid range.

func InvalidAuthError

func InvalidAuthError() error

InvalidAuthError constructs a gRPC error to indicate that the auth token is not valid. Valid tokens that aren't authorized for a particular action should use `InsufficientPermissionsError()` instead.

func InvalidIDFormat

func InvalidIDFormat(id *string) bool

InvalidIDFormat returns true if the provided ID is not a valid UUID v4.

func InvalidPhoneNumberFormat

func InvalidPhoneNumberFormat(phoneNumber *string) bool

InvalidPhoneNumberFormat returns true if a phone number string doesn't match the E.164 format: https://www.twilio.com/docs/glossary/what-e164

func IsEmpty

func IsEmpty(arg *string) bool

IsEmpty returns true if a string is empty.

func PlayerAlreadyExistsError

func PlayerAlreadyExistsError(eventKey *string, phoneNumber *string) error

PlayerAlreadyExistsError constructs a gRPC error to indicate that a conflicting registration already exists. This error response is deprecated.

func PlayerNotFoundError

func PlayerNotFoundError(playerID *string) error

PlayerNotFoundError constructs a gRPC error to indicate that the provided player ID was invalid.

func TemporaryServerError

func TemporaryServerError(err error) error

TemporaryServerError constructs a gRPC error to indicate that a miscellaneous server error has occurred, and that the request may be retried.

func TestMain

func TestMain(m *testing.M, testDBHolder **sql.DB, seedStatements []string)

TestMain is an override for the per-file TestMain that sets up a test database and runs all seed statements before the unit tests.

Types

This section is empty.

Jump to

Keyboard shortcuts

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