Documentation ¶
Index ¶
- Constants
- func FormatErrorMessage(field string, err validator.FieldError) string
- func GenerateOTP(length int) (string, error)
- func GenerateOrderCode(length int, charset string) (string, error)
- func GenerateUniqueNumber(length int) (string, error)
- func GetAuthUser(ctx context.Context) (map[string]interface{}, error)
- func GetCurrentTime() time.Time
- func GetJSONFieldMap(obj interface{}) map[string]string
- func JsonResponse(w http.ResponseWriter, statusCode int, data interface{})
- func ResponseValidation(w http.ResponseWriter, statusCode int, errors interface{}) error
- func ReturnResponse(w http.ResponseWriter, statusCode int, message string, data interface{})
- func Slugify(s string) string
- func StringToIntEnv(key string, defaultValue int) int
- func ValidateAndCollectErrors(w http.ResponseWriter, statusCode int, errors map[string]string, ...) map[string]string
- func ValidationResponse(w http.ResponseWriter, statusCode int, error interface{}, obj interface{})
- func WriteJSONEValidation(w http.ResponseWriter, statusCode int, error interface{})
- func WriteJSONError(w http.ResponseWriter, statusCode int, message string)
- func WriteJSONResponse(w http.ResponseWriter, statusCode int, data interface{})
- type Bool
- type CustomDateFormat
- type ErrorResponse
- type Response
Constants ¶
const (
ClaimsKey key = iota
)
Variables ¶
This section is empty.
Functions ¶
func FormatErrorMessage ¶ added in v1.3.8
func GenerateOTP ¶ added in v1.4.0
GenerateOTP generates a random OTP of the given length using numeric characters.
func GenerateOrderCode ¶ added in v1.4.0
GenerateOrderCode generates a random code of the given length using the provided character set.
func GenerateUniqueNumber ¶
func GetAuthUser ¶ added in v1.4.0
func GetCurrentTime ¶
func GetJSONFieldMap ¶ added in v1.3.8
GetJSONFieldMap uses reflection to map struct fields to their JSON tags
func JsonResponse ¶
func JsonResponse(w http.ResponseWriter, statusCode int, data interface{})
func ResponseValidation ¶
func ResponseValidation(w http.ResponseWriter, statusCode int, errors interface{}) error
func ReturnResponse ¶
func ReturnResponse(w http.ResponseWriter, statusCode int, message string, data interface{})
func StringToIntEnv ¶ added in v1.4.0
StringToIntEnv retrieves an environment variable as an integer, returning a default value if the conversion fails.
func ValidateAndCollectErrors ¶ added in v1.4.1
func ValidateAndCollectErrors(w http.ResponseWriter, statusCode int, errors map[string]string, error interface{}, obj interface{}) map[string]string
ValidateAndCollectErrors validates the input struct and returns any custom and validation errors found.
func ValidationResponse ¶ added in v1.3.8
func ValidationResponse(w http.ResponseWriter, statusCode int, error interface{}, obj interface{})
WriteJSONEValidation dynamically gets JSON tag fields and writes a validation error response
func WriteJSONEValidation ¶
func WriteJSONEValidation(w http.ResponseWriter, statusCode int, error interface{})
func WriteJSONError ¶
func WriteJSONError(w http.ResponseWriter, statusCode int, message string)
WriteJSONError writes a JSON error response with the specified status code and message.
func WriteJSONResponse ¶
func WriteJSONResponse(w http.ResponseWriter, statusCode int, data interface{})
WriteJSONResponse writes a JSON response with the specified status code.
Types ¶
type Bool ¶ added in v1.4.0
type Bool bool
func UnmarshalBool ¶ added in v1.4.0
UnmarshalBool is a reusable function that unmarshals both boolean and string representations
func (*Bool) UnmarshalJSON ¶ added in v1.4.0
UnmarshalJSON customizes the unmarshaling for the Bool type
type CustomDateFormat ¶
func (CustomDateFormat) MarshalJSON ¶
func (c CustomDateFormat) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface