helpers

package
v0.0.0-...-4605876 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseStackDriverErrorClient

func CloseStackDriverErrorClient(errorClient *errorreporting.Client)

CloseStackDriverErrorClient closes a StackDriver error client and logs any arising error.

It was written to be defer()'d in servrer initialization code.

func CloseStackDriverLoggingClient

func CloseStackDriverLoggingClient(loggingClient *logging.Client)

CloseStackDriverLoggingClient closes a StackDriver logging client and logs any arising error.

It was written to be defer()'d in servrer initialization code.

func GetEnvVar

func GetEnvVar(envVarName string) (string, error)

GetEnvVar retrieves the environment variable with the supplied name and fails if it is not able to do so

func GetPinExpiryDate

func GetPinExpiryDate() (*time.Time, error)

GetPinExpiryDate returns the expiry date for the given pin

func GetUserTokenFromContext

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

GetUserTokenFromContext retrieves a Firebase *auth.Token from the supplied context

func IsMSISDNValid

func IsMSISDNValid(msisdn string) bool

IsMSISDNValid uses regular expression to validate the a phone number

func LogStartupError

func LogStartupError(ctx context.Context, err error)

LogStartupError is used to e.g log fatal startup errors. It logs, attempts to report the error to StackDriver then panics/crashes.

func MustGetEnvVar

func MustGetEnvVar(envVarName string) string

MustGetEnvVar returns the value of the environment variable with the indicated name or panics. It is intended to be used in the INTERNALS of the server when we can guarantee (through orderly coding) that the environment variable was set at server startup. Since the env is required, kill the app if the env is not set. In the event a variable is not super required, set a sensible default or don't call this method

func NormalizeMSISDN

func NormalizeMSISDN(msisdn string) (*string, error)

NormalizeMSISDN validates the input phone number. For valid phone numbers, it normalizes them to international format e.g +2547........

func StackDriver

func StackDriver(ctx context.Context) *errorreporting.Client

StackDriver initializes StackDriver logging, error reporting, profiling etc

Types

This section is empty.

Jump to

Keyboard shortcuts

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