utils

package
v0.0.0-...-a2883fb Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPasswordHash

func CheckPasswordHash(password, hash string) bool

*

  • validation password hash

func ChiperDecrypt

func ChiperDecrypt(encryptedString string, keyString string) (string, error)

decrypt data using aes https://www.melvinvivas.com/how-to-encrypt-and-decrypt-data-using-aes

func ChiperEncrypt

func ChiperEncrypt(stringToEncrypt string, keyString string) (string, error)

encrypt data using aes https://www.melvinvivas.com/how-to-encrypt-and-decrypt-data-using-aes

func ContainsString

func ContainsString(s []string, str string) bool

Contains reports whether substr is within s.

func HashPassword

func HashPassword(password string) (string, error)

*

  • create password hash

func MapQueryParams

func MapQueryParams(r *http.Request, data interface{}) error

*

  • map query params to struct

func ParseTemplate

func ParseTemplate(templateFileName string, data interface{}) (string, error)

ref: https://github.com/Golang-Coach/Lessons/blob/master/GoMailer/template_helper.go

func RespondWithError

func RespondWithError(w http.ResponseWriter, code int, errors []error)

func RespondWithJSON

func RespondWithJSON(w http.ResponseWriter, code int, payload interface{})

func ResponseWithJsonMeta

func ResponseWithJsonMeta(w http.ResponseWriter, code int, payload interface{}, meta interface{})

func TimeUTC

func TimeUTC() time.Time

func TimestampToTime

func TimestampToTime(s string) time.Time

Types

type MetaResponse

type MetaResponse struct {
	Total   int `json:"total"`
	Page    int `json:"page"`
	PerPage int `json:"per_page"`
}

type StandardJwtClaims

type StandardJwtClaims struct {
	Audience  string `json:"aud,omitempty"`
	ExpiresAt int64  `json:"exp,omitempty"`
	Id        string `json:"jti,omitempty"`
	IssuedAt  int64  `json:"iat,omitempty"`
	Issuer    string `json:"iss,omitempty"`
	NotBefore int64  `json:"nbf,omitempty"`
	Subject   string `json:"sub,omitempty"`
	Name      string `json:"name,omitempty"`
}

func DecodeJwtToken

func DecodeJwtToken(token string) (claims *StandardJwtClaims, err error)

Jump to

Keyboard shortcuts

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