helper

package
v0.0.0-...-08c65b2 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2024 License: CC0-1.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorHandler

func ErrorHandler(c *gin.Context, err any)

func NewID

func NewID() (string, error)

func Ternary

func Ternary(condition bool, tru, fals any) any

Types

type AuthTokenService

type AuthTokenService interface {
	GenerateToken(payload interface{}) (string, error)
	ValidateToken(token string) (*jwt.Token, error)
}

func NewAuthTokenService

func NewAuthTokenService() AuthTokenService

type BadRequestError

type BadRequestError struct {
	Message string
}

func NewBadRequestError

func NewBadRequestError(msg string) BadRequestError

func (BadRequestError) Error

func (e BadRequestError) Error() string

type FileService

type FileService interface {
	Upload(params UploadParams) (string, error)
	OpenFormFile(c *gin.Context, fh *multipart.FileHeader) (multipart.File, error)
	ValidateImage(c *gin.Context, fh *multipart.FileHeader, field string, maxSize int64) error
}

func NewFileService

func NewFileService() FileService

type NotFoundError

type NotFoundError struct {
	Message string
}

func NewNotFoundError

func NewNotFoundError(msg string) NotFoundError

func (NotFoundError) Error

func (e NotFoundError) Error() string

type PaginationMeta

type PaginationMeta struct {
	CurrentPage int `json:"current_page"`
	NextPage    int `json:"next_page"`
	PrevPage    int `json:"prev_page"`
	TotalPage   int `json:"total_page"`
	TotalData   int `json:"total_data"`
}

type ResponseDto

type ResponseDto struct {
	Code    int         `json:"code"`
	Status  string      `json:"status"`
	Message string      `json:"message"`
	Data    interface{} `json:"data"`
}

func WrapperResponse

func WrapperResponse(code int, status string, message string, data interface{}) ResponseDto

type UnauthorizedError

type UnauthorizedError struct {
	Message string
}

func NewUnauthorizedError

func NewUnauthorizedError(msg string) UnauthorizedError

func (UnauthorizedError) Error

func (e UnauthorizedError) Error() string

type UploadParams

type UploadParams struct {
	File io.Reader
	Dest string
}

Jump to

Keyboard shortcuts

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