helpers

package
v2.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculatePKCEChallengeS256

func CalculatePKCEChallengeS256(codeVerifier string) string

CalculatePKCEChallengeS256 calculates the S256 PKCE code challenge. It takes the code verifier, computes its SHA256 hash, and then Base64 URL encodes the hash.

func CopyRequestBody

func CopyRequestBody(r *http.Request) ([]byte, error)

func DaysLeft

func DaysLeft(targetDate time.Time) int

func DecodeToUTF8

func DecodeToUTF8(s string) (string, error)

func EstimateTokenCount

func EstimateTokenCount(text string) int

func GenerateRandomString

func GenerateRandomString(length int) string

func HashString

func HashString(s string) string

func IntToObjectId

func IntToObjectId(id uint) *string

func KeyValueInt32OrZero

func KeyValueInt32OrZero(dat map[string]any, key string) int

func KeyValueOrZero

func KeyValueOrZero(dat map[string]any, key string) int

func SendErrorResponse

func SendErrorResponse(c *gin.Context, err error)

SendErrorResponse sends a standardized error response to the client It handles different error types, particularly ErrorResponse

func ValidateEmailDomain

func ValidateEmailDomain(email string) error

Types

type ErrorResponse

type ErrorResponse struct {
	StatusCode int
	Title      string
	Message    string
}

func NewBadRequestError

func NewBadRequestError(message string) ErrorResponse

Helper functions

func NewForbiddenError

func NewForbiddenError(message string) ErrorResponse

func NewInternalServerError

func NewInternalServerError(message string) ErrorResponse

func NewNotFoundError

func NewNotFoundError(message string) ErrorResponse

func NewPaymentRequiredError

func NewPaymentRequiredError(message string) ErrorResponse

func NewUnauthorizedError

func NewUnauthorizedError(message string) ErrorResponse

func (ErrorResponse) Error

func (e ErrorResponse) Error() string

type JSONMapAccessor

type JSONMapAccessor struct {
	// contains filtered or unexported fields
}

JSONMapAccessor provides convenient access to values in a JSONMap

func NewJSONMapAccessor

func NewJSONMapAccessor(data map[string]interface{}) *JSONMapAccessor

NewJSONMapAccessor creates a new JSONMapAccessor

func (*JSONMapAccessor) GetSlice

func (a *JSONMapAccessor) GetSlice(key string) []interface{}

GetSlice retrieves a []interface{} value from the JSONMap

func (*JSONMapAccessor) GetString

func (a *JSONMapAccessor) GetString(key, defaultValue string) string

GetString retrieves a string value from the JSONMap

Jump to

Keyboard shortcuts

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