utils

package
v0.0.0-...-faa9808 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InArray

func InArray[T comparable](needle T, haystack []T) bool

func NewHTTPRespond

func NewHTTPRespond(context *gin.Context, code int, data interface{}, args ...any)

func ParseParam

func ParseParam(ctx *gin.Context, filterBetween bool) ([]int, []string)

ParseParam SECURITY ISSUE? - when add query from delivery

Types

type ErrorRespond

type ErrorRespond struct {
	Code   int    `json:"code"`
	Status string `json:"status"`
	Data   string `json:"data"`
}

ErrorRespond message

type Paging

type Paging struct {
	URL  string `json:"url"`
	Path string `json:"path"`
}

func Paginate

func Paginate(limit, offset, total int, host, path string) (totalPages, currentPage int, next, prev Paging)

type ServiceError

type ServiceError struct {
	Code    int
	Message any
}

func ValidateDataRow

func ValidateDataRow[T any](data *T, err error) (valueData *T, errData *ServiceError)

func ValidateDataRows

func ValidateDataRows[T any](data []*T, err error) (valueData []*T, errData *ServiceError)

func ValidatePrimitiveValue

func ValidatePrimitiveValue[T any](data T, err error) (valueData T, errData *ServiceError)

type SuccessRespond

type SuccessRespond struct {
	Code   int    `json:"code"`
	Status string `json:"status"`
	Data   any    `json:"data"`
}

SuccessRespond message

type SuccessRespondWithPagination

type SuccessRespondWithPagination struct {
	Code     int    `json:"code"`
	Status   string `json:"status"`
	Count    int    `json:"total_data"`
	Total    int    `json:"total_page"`
	Current  int    `json:"current_page"`
	Next     Paging `json:"next"`
	Previous Paging `json:"previous"`
	Data     any    `json:"data"`
}

SuccessRespondWithPagination message

Jump to

Keyboard shortcuts

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