util

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

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

Go to latest
Published: Aug 7, 2023 License: MIT Imports: 22 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 APIResponsePagination

func APIResponsePagination(ctx *gin.Context, Message string, StatusCode int, Method string, Data interface{}, Pagination interface{})

func ComparePassword

func ComparePassword(hashPassword string, password string) error

func GodotEnv

func GodotEnv(key string) string

func HashPassword

func HashPassword(password string) string

func ParseHtml

func ParseHtml(fileName string, data map[string]string) string

func SendGridMail

func SendGridMail(name, email, subject, fileName, token string) (*rest.Response, error)

func Sign

func Sign(Data map[string]interface{}, SecrePublicKeyEnvName string, ExpiredAt time.Duration) (string, error)

func Validator

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

Validation request from struct field

func ValidatorErrorResponse

func ValidatorErrorResponse(ctx *gin.Context, StatusCode int, Method string, Error interface{})

func VerifyToken

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

func VerifyTokenHeader

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

Types

type AccessToken

type AccessToken struct {
	Claims MetaToken
}

func DecodeToken

func DecodeToken(accessToken *jwt.Token) AccessToken

type BodyRequest

type BodyRequest struct {
	To    string
	Token string
}

type ErrorResponse

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

type MetaToken

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

type Paginate

type Paginate struct {
	Limit int `json:"limit" form:"limit"`
	Page  int `json:"page" form:"page"`
}

func NewPaginate

func NewPaginate(limit int, page int) *Paginate

func (*Paginate) PaginatedResult

func (p *Paginate) PaginatedResult(db *gorm.DB) *gorm.DB

type PaginateScope

type PaginateScope interface {
	PaginatedResult() *gorm.DB
}
		return db.Offset(int(offset)).Limit(int(limit))
	}
}

type Responses

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

type ResponsesPagination

type ResponsesPagination struct {
	Pagination interface{} `json:"pagination"`
	Responses
}

Jump to

Keyboard shortcuts

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