utils

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SentEmailsDuringTests = SentEmailsDuringTestsType{
	SentEmails: make([]SentEmail, 0),
}

Functions

func APIBadResponse

func APIBadResponse(error string) gin.H

func APINoMethodFound

func APINoMethodFound() gin.H

func APISuccessResp

func APISuccessResp() gin.H

func CheckRateLimit

func CheckRateLimit(r *http.Request) bool

CheckRateLimit checks if the request has remaining quota or not. If it returns false, the IP in the request has exceeded their quota

func Commaf

func Commaf(j interface{}) string

commaf is a function to format number with thousand separator and two decimal points

func Decrypt

func Decrypt(key []byte, securemess string) (decodedmess string, err error)

func Encrypt

func Encrypt(key []byte, message string) (encmess string, err error)

func GenerateBase32

func GenerateBase32(length int) string

GenerateBase32 generates a base64 string of length length

func GenerateBase64

func GenerateBase64(length int) string

GenerateBase64 generates a base64 string of length length

func GenerateCSRFToken

func GenerateCSRFToken() string

func GenerateRandomStringForCSRFToken

func GenerateRandomStringForCSRFToken() string

func GetString

func GetString(a interface{}) string

GetString returns string representation on an instance of a model

func IsLocal

func IsLocal(Addr string) bool

func MaskCSRFToken

func MaskCSRFToken(token string) string

func RandStringRunes

func RandStringRunes(n int) string

func RandStringRunesForOneTimeAction

func RandStringRunesForOneTimeAction(n int) string

func SendEmail

func SendEmail(from string, to []string, cc []string, bcc []string, subject string, body string) error

@todo rework SendEmail sends email using system configured variables

func UnmaskCSRFToken

func UnmaskCSRFToken(token string) string

Types

type SentEmail

type SentEmail struct {
	From    string
	To      []string
	Subject string
	CC      []string
	Message []byte
}

type SentEmailsDuringTestsType

type SentEmailsDuringTestsType struct {
	SentEmails []SentEmail
}

func (*SentEmailsDuringTestsType) AddSentEmail

func (se *SentEmailsDuringTestsType) AddSentEmail(from string, to []string, subject string, CC []string, message []byte)

func (*SentEmailsDuringTestsType) ClearTestEmails

func (se *SentEmailsDuringTestsType) ClearTestEmails()

func (*SentEmailsDuringTestsType) IsAnyEmailSentWithStringInBodyOrSubject

func (se *SentEmailsDuringTestsType) IsAnyEmailSentWithStringInBodyOrSubject(expectedEmail *SentEmail) bool

func (*SentEmailsDuringTestsType) IsAnyMatchedEmailSent

func (se *SentEmailsDuringTestsType) IsAnyMatchedEmailSent(expectedEmail *SentEmail) bool

Jump to

Keyboard shortcuts

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