ginutils

package
v0.1.15 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateResponse

func GenerateResponse(status int, c *gin.Context, data interface{}, meta *models.Metadata)

GenerateResponse generates a response for the api

func GetClaims

func GetClaims(c *gin.Context) (models.ISClaims, error)

GetClaims returns info out of jwt token

func GetRoles

func GetRoles(c *gin.Context) []string

GetRoles returns the roles for the user

func IndexOfString

func IndexOfString(element string, data []string) int

IndexOfString finds the index of an item in a string array. This is case insensitive and returns -1 if not found

func IsInRole

func IsInRole(c *gin.Context, role string) bool

IsInRole returns if a user is in specified Role

func RunTransaction

func RunTransaction(db *gorm.DB, fn txnFunc) error

RunTransaction is a wrapper for a transaction. This automatically re-calls `fn` with the open transaction as an argument as long as the database server asks for the transaction to be retried.

Types

This section is empty.

Jump to

Keyboard shortcuts

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