util

package
v0.0.0-...-d49efea Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func APIResponse

func APIResponse(ctx *gin.Context, message string, statusCode int, method string, data interface{})

func ComparePassword

func ComparePassword(hashPassword string, password string) error

func ErrorResponse

func ErrorResponse(ctx *gin.Context, message string, statusCode int, method string, err interface{})

func GodotEnv

func GodotEnv(key string) string

func HashPassword

func HashPassword(password string) (string, error)

func Sign

func Sign(data map[string]interface{}, secretPublicKeyEnvName string, expiredAt time.Duration) (string, error)

func Validator

func Validator(s interface{}, tagName string) error

Validator function to validate struct fields based on tags

func VerifyToken

func VerifyToken(accessToken, SecretPublicKeyEnvName string) (*jwt.Token, error)

func VerifyTokenHeader

func VerifyTokenHeader(ctx *gin.Context, SecretPublicKeyEnvName string) (*jwt.Token, error)

Types

type AccessToken

type AccessToken struct {
	Claims MetaToken
}

func DecodeToken

func DecodeToken(accessToken *jwt.Token) (AccessToken, error)

type BaseError

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

BaseError defines a standard error structure for the application.

func NewBaseError

func NewBaseError(code, message string) *BaseError

NewBaseError creates a new instance of BaseError.

func (*BaseError) Error

func (e *BaseError) Error() string

Error implements the error interface for BaseError.

type ErrorResponseEntity

type ErrorResponseEntity struct {
	StatusCode int         `json:"statusCode"`
	Method     string      `json:"method"`
	Message    string      `json:"message"`
	Error      interface{} `json:"error"`
}

type MetaToken

type MetaToken struct {
	ID            string
	Email         string
	ExpiredAt     time.Time
	Authorization bool
}

type ResponsesEntity

type ResponsesEntity struct {
	StatusCode int         `json:"statusCode"`
	Method     string      `json:"method"`
	Message    string      `json:"message"`
	Data       interface{} `json:"data"`
}

Jump to

Keyboard shortcuts

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