helper

package
v1.9.5 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2026 License: MIT Imports: 23 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthHeadersFromContext added in v1.8.0

func AuthHeadersFromContext(ctx context.Context) map[string]string

func CopySourceToFile added in v1.1.1

func CopySourceToFile(fileName string, source io.Reader) error

func FileTypeAllowed added in v1.1.0

func FileTypeAllowed(fileHeader *multipart.FileHeader, allowed map[string]bool) (bool, string, error)

func FinalizeTransaction added in v1.3.3

func FinalizeTransaction(opt FinalizeTransactionOpt)

func GenerateDeviceHash added in v1.5.0

func GenerateDeviceHash(ctx context.Context, accountId int64) string

func HashSHA512 added in v1.5.0

func HashSHA512(str string) string

func HealthOK

func HealthOK(ctx *gin.Context)

func InjectValues added in v0.0.4

func InjectValues(ctx context.Context, values map[appconstant.ContextKey]any) context.Context

func LooksLikeCSV added in v1.8.4

func LooksLikeCSV(b []byte) bool

func MultipartFromFilePath added in v1.8.8

func MultipartFromFilePath(fieldName, filePath string) (*multipart.FileHeader, multipart.File, error)

func NewCSVReader added in v1.8.7

func NewCSVReader(file multipart.File) (*csv.Reader, error)

func NewHashHelper

func NewHashHelper(config HashConfig) *hashHelperImpl

func NewJWTHelper added in v0.0.2

func NewJWTHelper(config JwtConfig, method jwt.SigningMethod) *jwtHelperImpl

func NewLogrus

func NewLogrus() *logrus.Logger

Deprecated. Use SetupLogrus instead.

func ReadCSVFromUpload added in v1.8.6

func ReadCSVFromUpload(file multipart.File) ([]string, [][]string, error)

func ResponseOK

func ResponseOK(ctx *gin.Context, res any)

func SetupLogrus added in v1.9.5

func SetupLogrus(logLevel string, dir string) error

Types

type FinalizeTransactionOpt added in v1.3.3

type FinalizeTransactionOpt struct {
	Commit   func() error
	Rollback func() error

	Err *error

	LogTag string
}

type HashConfig

type HashConfig struct {
	HashCost int `json:"hash_cost"`
}

type HashHelper

type HashHelper interface {
	Hash(str string) (string, error)
	Check(str string, hash []byte) (bool, error)
}

type JWTHelper

type JWTHelper interface {
	CreateAndSign(customClaimBytes []byte, expiredAt int64) (string, error)
	ParseAndVerify(signed string) ([]byte, error)
}

type JwtConfig

type JwtConfig struct {
	Issuer string `json:"issuer"`
	Key    string `json:"key"`
}

type SmtpHelper added in v1.4.1

type SmtpHelper struct {
	// contains filtered or unexported fields
}

func NewSmptpHelper added in v1.4.0

func NewSmptpHelper(config entity.SmtpHelperConfig) *SmtpHelper

func (*SmtpHelper) NewRequest added in v1.4.1

func (h *SmtpHelper) NewRequest(to []string, subject string) *smtpRequest