utils

package
v1.3.5 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2024 License: MIT Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateUniqueNumber

func GenerateUniqueNumber(length int) string

func GetCurrentTime

func GetCurrentTime() time.Time

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 Slugify

func Slugify(s string) string

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 CustomDateFormat

type CustomDateFormat time.Time

func (CustomDateFormat) MarshalJSON

func (c CustomDateFormat) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface

type ErrorResponse

type ErrorResponse struct {
	Success bool        `json:"success"`
	Message string      `json:"message,omitempty"`
	Errors  interface{} `json:"errors,omitempty"`
}

type Response

type Response struct {
	Success bool        `json:"success"`
	Message string      `json:"message,omitempty"`
	Data    interface{} `json:"data,omitempty"`
}

Response represents a standardized JSON response format.

Jump to

Keyboard shortcuts

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