helpers

package
v0.0.0-...-7f3c82a Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2023 License: MIT Imports: 15 Imported by: 2

Documentation

Index

Constants

View Source
const (
	TagNameValidate             = "validate"
	TagNameTransform            = "transform"
	TagNameJSON                 = "json"
	TransformStrEncrypt         = "encrypt"
	TransformStrDecrypt         = "decrypt"
	TransformStrHash            = "hash"
	TransformStrPasswordHash    = "passwordhash"
	TransformStrTruncate        = "truncate"
	TransformStrTrimChars       = "trimchars"
	TransformStrTrimSpace       = "trimspace"
	TransformStrDefault         = "default"
	ValidateStrMaxLength        = "maxlength"
	ValidateStrMinLength        = "minlength"
	ValidateStrGreaterThan      = "greaterthan"
	ValidateStrLessThan         = "lessthan"
	ValidateStrRequired         = "required"
	ValidateStrMustHaveChars    = "musthavechars"
	ValidateStrCantHaveChars    = "canthavechars"
	ValidateStrOnlyHaveChars    = "onlyhavechars"
	ValidateStrMaxLengthErr     = "Failed Max Length Validation"
	ValidateStrMinLengthErr     = "Failed Min Length Validation"
	ValidateStrRequiredErr      = "Failed Required Validation"
	ValidateStrMustHaveCharsErr = "Failed Must Have Chars Validation"
	ValidateStrCantHaveCharsErr = "Failed Can't Have Chars Validation"
	ValidateStrOnlyHaveCharsErr = "Failed Only Have Chars Validation"
	ValidateStrGreaterThanErr   = "Failed Greater Than Validation"
	ValidateStrLessThanErr      = "Failed Less Than Validation"
)

Variables

View Source
var (
	TypeOfString   = reflect.TypeOf(dummyString)
	TypeOfInt      = reflect.TypeOf(dummyInt)
	TypeOfInt64    = reflect.TypeOf(dummyInt64)
	TypeOfFloat32  = reflect.TypeOf(dummyFloat32)
	TypeOfFloat64  = reflect.TypeOf(dummyFloat64)
	TypeOfBool     = reflect.TypeOf(dummyBool)
	TypeOfStringP  = reflect.TypeOf(dummyStringP)
	TypeOfIntP     = reflect.TypeOf(dummyIntP)
	TypeOfInt64P   = reflect.TypeOf(dummyInt64P)
	TypeOfFloat32P = reflect.TypeOf(dummyFloat32P)
	TypeOfFloat64P = reflect.TypeOf(dummyFloat64P)
	TypeOfBoolP    = reflect.TypeOf(dummyBoolP)
)
View Source
var CORSOrigins = []string{
	"http://localhost",
	"http://127.0.0.1",
	"http://www.example.com",
	"https://localhost",
	"https://127.0.0.1",
	"https://www.example.com",
}

Functions

func DecryptReflectValue

func DecryptReflectValue(value reflect.Value) (err error)

func EncryptReflectValue

func EncryptReflectValue(value reflect.Value) (err error)

func ErrorJSON

func ErrorJSON(msg string) (out string)

func HandleMiddlewares

func HandleMiddlewares(handlerFunc http.HandlerFunc, middlewares ...func(http.HandlerFunc) http.HandlerFunc) (h http.HandlerFunc)

Usage: HandleMiddlewares(PersonHandlerGET, MiddlewareNoCache, MiddlewareCORS)(w, r)

func MiddlewareCORS

func MiddlewareCORS(fn http.HandlerFunc) http.HandlerFunc

func MiddlewareLogger

func MiddlewareLogger(fn http.HandlerFunc) http.HandlerFunc

func MiddlewareNoCache

func MiddlewareNoCache(fn http.HandlerFunc) http.HandlerFunc

func PasswordHashReflectValue

func PasswordHashReflectValue(value reflect.Value) (err error)

func SetDefaultValue

func SetDefaultValue(value reflect.Value, defaultStr string) (err error)

func Transform

func Transform(in interface{}) (err error)

func TransformString

func TransformString(param string, value reflect.Value) (err error)

func Unmarshal

func Unmarshal(r *http.Request, dst interface{}) (err error)

func Validate

func Validate(in interface{}) (msg string, err error)

func ValidateFloat64

func ValidateFloat64(param string, in float64) (msg string)

func ValidateInt

func ValidateInt(param string, in int) (msg string)

func ValidateString

func ValidateString(param, in string) (msg string)

func WriteJSON

func WriteJSON(out interface{}, w http.ResponseWriter)

Types

This section is empty.

Jump to

Keyboard shortcuts

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