utils

package
v0.0.0-...-25e7f04 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorJSON

func ErrorJSON(w http.ResponseWriter, err error, status ...int) error

func GenerateRandomBytes

func GenerateRandomBytes(n int) ([]byte, error)

GenerateRandomBytes returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.

func GenerateRandomString

func GenerateRandomString(n int) (string, error)

GenerateRandomString returns a securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.

func GenerateRandomStringURLSafe

func GenerateRandomStringURLSafe(n int) (string, error)

GenerateRandomStringURLSafe returns a URL-safe, base64 encoded securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.

func GetMapstructureTags

func GetMapstructureTags(o any) []string

func WriteJSON

func WriteJSON(w http.ResponseWriter, status int, data interface{}, headers ...http.Header) error

Types

type JSONResponse

type JSONResponse struct {
	Error       bool        `json:"error"`
	Message     string      `json:"message"`
	Status      string      `json:"status,omitempty"`
	RedirectURL string      `json:"redirect_url,omitempty"`
	Data        interface{} `json:"data,omitempty"`
}

Jump to

Keyboard shortcuts

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