utils

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2021 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareHash

func CompareHash(hash []byte, password []byte) error

CompareHash if hash and plan are equal

func CreateEmailVerficationToken

func CreateEmailVerficationToken()

func Find added in v0.1.4

func Find(slice []string, val string) (int, bool)

Find takes a slice and looks for an element in it. If found it will return it's key, otherwise it will return -1 and a bool of false.

func GenerateDigits

func GenerateDigits(max int) string

GenerateDigits generate fix length of digits

func GenerateJWTToken

func GenerateJWTToken(privateKeydata []byte, claim TokenClaims, expireOffsetHour int64) (string, error)

GenerateJWTToken

func GetFilesContents

func GetFilesContents(files ...string) map[string][]byte

func GetIPAdress

func GetIPAdress(r *http.Request) string

GetIPAdress get request source ip address

func GetInterfaceType

func GetInterfaceType(input interface{}) string

GetInterfaceType get inteface type

func GetInterfaceTypeLower

func GetInterfaceTypeLower(input interface{}) string

GetInterfaceType get inteface type

func GetPrettyURL

func GetPrettyURL() string

GetPrettyURL return *config.AppConfig.BaseRoute

func GetPrettyURLf

func GetPrettyURLf(url string) string

GetPrettyURL formats according to pretty URL from (baseFunctionURL+url) and returns the resulting string.

func GetType

func GetType(s string) string

GetType get inteface type without package name

func GetTypeLowerFirst

func GetTypeLowerFirst(s string) string

GetTypeLowerFirst get inteface type without package name with lowercase first character

func Hash

func Hash(text string) ([]byte, error)

Hash convert txt to hash

func IsTimeExpired

func IsTimeExpired(timestamp int64, offsetInSeconds float64) bool

IsTimeExpired check time expiration in unix

func IsTimeExpiredInTime

func IsTimeExpiredInTime(tt time.Time, offsetInSeconds float64) bool

IsTimeExpired check time expiration in golang time

func LowerFirst

func LowerFirst(s string) string

LowerFirst lower case the first character of string

func MarshalError

func MarshalError(code string, message string) []byte

func MomentToTime

func MomentToTime(moment string) (time.Time, error)

MomentToTime Covert moment unix to time.Time

func ParseHtmlBytesTemplate

func ParseHtmlBytesTemplate(templateFilePath string, data interface{}) ([]byte, error)

ParseHtmlBytesTemplate parse html template return in []byte

func ParseHtmlTemplate

func ParseHtmlTemplate(templateFilePath string, data interface{}) (string, error)

ParseHtmlTemplate parse html template return in string

func ReadSecret

func ReadSecret(key string) (string, error)

ReadSecret reads a secret from /var/openfaas/secrets or from env-var 'secret_mount_path' if set.

func TimeUnix

func TimeUnix(inputTime time.Time) int64

UTCNow Get moment UTC NOW

func UTCNowUnix

func UTCNowUnix() int64

UTCNow Get moment UTC NOW

func UTCUnixToTime

func UTCUnixToTime(timestamp int64) time.Time

UTCUnixToTime Get UTC unix time in go time

func ValidateToken

func ValidateToken(keydata []byte, token string) (jwt.MapClaims, error)

ValidateToken

Types

type Email

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

Request struct

func NewEmail

func NewEmail(refEmail string, password string, smtpEmail string) *Email

func (*Email) SendEmail

func (email *Email) SendEmail(req *Request, tmplPath string, data interface{}) (bool, error)

type ErrorCodeMessage added in v0.1.11

type ErrorCodeMessage struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

type PhoneClient

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

func NewPhone

func NewPhone(authId string, authToken string, sourceNumber string) (*PhoneClient, error)

NewPhone initialize phone config

func (*PhoneClient) SendSms

func (pc *PhoneClient) SendSms(phoneNumber string, message string) ([]string, error)

SendSms send sms

type Recaptcha

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

func NewRecaptha

func NewRecaptha(key string) *Recaptcha

Init allows the webserver or code evaluating the reCaptcha form input to set the reCaptcha private key (string) value, which will be different for every domain.

func (*Recaptcha) VerifyCaptch

func (recap *Recaptcha) VerifyCaptch(recaptchaResponse string, remoteIpAddress string) (bool, error)

VerifyCaptch verifying recaptcha

type RecaptchaResponse

type RecaptchaResponse struct {
	Success     bool      `json:"success"`
	Score       float64   `json:"score"`
	Action      string    `json:"action"`
	ChallengeTS time.Time `json:"challenge_ts"`
	Hostname    string    `json:"hostname"`
	ErrorCodes  []string  `json:"error-codes"`
}

type Request

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

Request struct

func NewEmailRequest

func NewEmailRequest(to []string, subject, body string) *Request

type TelarError added in v0.1.11

type TelarError struct {
	Error ErrorCodeMessage `json:"error"`
}

func Error added in v0.1.11

func Error(code string, message string) TelarError

type TokenClaims

type TokenClaims struct {
	// Meta data
	Claim interface{} `json:"claim"`

	// Inherit from standard claims
	jwt.StandardClaims
}

Jump to

Keyboard shortcuts

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