utils

package
v0.0.0-...-cfa2258 Latest Latest
Warning

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

Go to latest
Published: May 19, 2020 License: Apache-2.0 Imports: 20 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthRequired

func AuthRequired() gin.HandlerFunc

func AutoMigrateDB

func AutoMigrateDB(db *gorm.DB)

Create tables in the database and run migrations of models change

func Backup

func Backup() error

Create a backup of the database

func CurrentTime

func CurrentTime() string

func DbConnect

func DbConnect() (*gorm.DB, error)

Returns a connection to db or error Connects to DB depending on the APP_ENV, by using APP_ENV value as a prefix to db credentials i.e, if APP_ENV=prod, it will connect to the production db, same for local, dev, staging APP_ENV=local, it will connect to localhost db APP_ENV=dev, it will connect to shared dev db APP_ENV=staging, it will connect to the staging db

func ExitApp

func ExitApp(code int)

func ExtractUser

func ExtractUser(c *gin.Context) (username string, userId int)

func GenerateUUID

func GenerateUUID() string

func InitLogger

func InitLogger() error

func Log

func Log(msg ...interface{})

func LogError

func LogError(msg ...interface{})

func LogInfo

func LogInfo(msg ...interface{})

func LogWarning

func LogWarning(msg ...interface{})

func MetricsMonitor

func MetricsMonitor() gin.HandlerFunc

func NotifyError

func NotifyError(message string)

func RedisConnect

func RedisConnect() (client *redis.Client)

Connect to REDIS for caching

func RespondWithError

func RespondWithError(w http.ResponseWriter, code int, msg string)

func RespondWithJSON

func RespondWithJSON(w http.ResponseWriter, code int, payload interface{})

func SeedDB

func SeedDB(db *gorm.DB)

Insert initial data into database

func SendError

func SendError(c *gin.Context, msg string)

func SendGet

func SendGet(url string) (result map[string]interface{}, err error)

func SendJson

func SendJson(c *gin.Context, payload gin.H)

func SendMail

func SendMail(from, toName, to, subject, body string) (ok bool, err error)

func SendPost

func SendPost(url string, payload map[string]interface{}) (result map[string]interface{}, err error)

func ValidateEmail

func ValidateEmail(email string) (bool, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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