helper

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BasicAuth

func BasicAuth(user, password string) string

BasicAuth creates the base64 encoded string containing user:password for basic authentication headers

func CompareStringSlices

func CompareStringSlices(sliceA, sliceB []string) bool

CompareStringSlices takes two string slices and compares its content. Returns true if both slices contain the same elements and the same number of elements. It does not check the order.

func CreatePaginationMeta

func CreatePaginationMeta(total, limit, page, seed int) *base_models.PaginationResult

func EliminateDuplicates

func EliminateDuplicates[T comparable](input []T) (result []T)

func ExtractFullAuth0IdFromContext

func ExtractFullAuth0IdFromContext(c *gin.Context) (auth0FullId string, err error)

func ExtractLanguageFromContext

func ExtractLanguageFromContext(c *gin.Context) (language *base_models.Language, err error)

func ExtractUserFromContext

func ExtractUserFromContext(c *gin.Context) (user *base_models.User, err error)

func GenerateRandomString

func GenerateRandomString(length int, pools ...Pool) (string, error)

func InitSlice

func InitSlice[T comparable](length int, defaultValue T) (result []T)

InitSlice initializes a new slice of the length and initializes each field with the given default value

func IntegerToInterfaceSlice

func IntegerToInterfaceSlice(input []int) []interface{}

func MustExtractFullAuth0IdFromContext

func MustExtractFullAuth0IdFromContext(c *gin.Context) (auth0FullId string)

func MustExtractLanguageFromContext

func MustExtractLanguageFromContext(c *gin.Context) *base_models.Language

func MustExtractUserFromContext

func MustExtractUserFromContext(c *gin.Context) *base_models.User

func MustGenerateNewUid

func MustGenerateNewUid() uint64

func ParsePaginationInput

func ParsePaginationInput(input *base_input.Pagination)

func ParseSearchInput

func ParseSearchInput(inputSearchPairs []string, allowedSearchFields []string) (searchPairs []base_input.SearchPair, err error)

func ParseSortInput

func ParseSortInput(inputSortPairs []string, allowedSortFields []string, defaultField string, defaultDir base_input.Direction) (sortPairs []base_input.SortPair, err error)

func ReadResponseBody

func ReadResponseBody(response *http.Response, target interface{}) error

ReadResponseBody reads the body of the given response without modifying it and tries to unmarshal it into the given target interface.

func RemoveElement

func RemoveElement[T comparable](input []T, removeElement T) (result []T)

func ReportPrivateError

func ReportPrivateError(c *gin.Context, apiError *response.ApiError, meta interface{})

func ReportPrivateErrorAndAbort

func ReportPrivateErrorAndAbort(c *gin.Context, apiError *response.ApiError, meta interface{})

func ReportPublicError

func ReportPublicError(c *gin.Context, apiError *response.ApiError, meta interface{})

func ReportPublicErrorAndAbort

func ReportPublicErrorAndAbort(c *gin.Context, apiError *response.ApiError, meta interface{})

func SliceContains

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

func StringSliceContains

func StringSliceContains(haystack []string, needle string) bool

func StringToInterfaceSlice

func StringToInterfaceSlice(input []string) []interface{}

func ToAnySlice

func ToAnySlice[T any](input []T) []any

func UploadMimetypeContains

func UploadMimetypeContains(file *multipart.FileHeader, hasMime string) (contains bool, err error)

func WrapErrorWithEmail

func WrapErrorWithEmail(err error, email string) error

func WrapErrorWithEosnId

func WrapErrorWithEosnId(err error, eosnId string) error

func WrapErrorWithId

func WrapErrorWithId(err error, id int) error

func WrapErrorWithName

func WrapErrorWithName(err error, name string) error

Types

type Pool

type Pool string
const (
	UppercaseLetterPool Pool = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
	LowercaseLetterPool Pool = "abcdefghijklmnopqrstuvwxyz"
	NumberPool          Pool = "0123456789"
	AlphanumericPool    Pool = UppercaseLetterPool + LowercaseLetterPool + NumberPool
)

Jump to

Keyboard shortcuts

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