utils

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

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 GetString

func GetString(a interface{}) string

GetString returns string representation on an instance of a model

func IsLocal

func IsLocal(Addr string) bool

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

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