util

package
v0.0.0-...-8b35975 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeMD5

func EncodeMD5(value string) string

EncodeMD5 md5 encryption

func GenerateToken

func GenerateToken(user *models.User) (string, error)

GenerateToken generate tokens used for auth

func Hash

func Hash(password string) (string, error)

Hash return hash password

func LogStart

func LogStart(version string, timeStart time.Time)

LogStart to display the version and the time start of service

func PasswordMatch

func PasswordMatch(hashed, password string) error

PasswordMatch return and error if match is't invalid

Types

type Claims

type Claims struct {
	jwt.StandardClaims
	Identity *models.User `json:"identity"`
}

func ParseToken

func ParseToken(token string) (*Claims, error)

ParseToken parsing token

type ContextKey

type ContextKey string

ContextKey type

const ContextKeyTx ContextKey = "tx"

ContextKeyTx key

type TxLogger

type TxLogger struct {
	Tx     *sqlx.Tx
	Logger *logrus.Logger
}

TxLogger is sqlx.Tx wrapper with injected logger

func (*TxLogger) Exec

func (tx *TxLogger) Exec(query string, args ...interface{}) (sql.Result, error)

Exec executes a query that doesn't return rows. For example: an INSERT and UPDATE.

func (*TxLogger) Get

func (tx *TxLogger) Get(dest interface{}, query string, args ...interface{}) error
Implementation of sqlx.Tx wrap logging

Get within a transaction. Any placeholder parameters are replaced with supplied args. An error is returned if the result set is empty.

func (*TxLogger) QueryRowx

func (tx *TxLogger) QueryRowx(query string, dest interface{}, args ...interface{}) error

QueryRowx executes a query that return rows. For example: an INSERT and UPDATE.

func (*TxLogger) QueryRowxStruct

func (tx *TxLogger) QueryRowxStruct(query string, dest interface{}, args ...interface{}) error

QueryRowxStruct executes a query that return rows.

func (*TxLogger) Select

func (tx *TxLogger) Select(dest interface{}, query string, args ...interface{}) error

Select within a transaction. Any placeholder parameters are replaced with supplied args.

Jump to

Keyboard shortcuts

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