utils

package
v0.0.0-...-dbd7cec Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2025 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Validator = validator.New()

Functions

func CopyFileIntoResponse

func CopyFileIntoResponse(dir string, filename string, w http.ResponseWriter)

func CreateSlug

func CreateSlug(title string) string

func DeleteCookie

func DeleteCookie(w http.ResponseWriter, cookie *http.Cookie)

func FileUploadHandler

func FileUploadHandler(
	field string,
	maxSizeInMB int64,
	mimeTypes []string,
	directory string,
) http.HandlerFunc

func FilterStruct

func FilterStruct(input any, exposures map[string]bool) map[string]any

func GetPageCount

func GetPageCount(totalEntities int64, pageLimit int64) int32

func ParseIntURLParam

func ParseIntURLParam(name string, vars map[string]string) (int, error)

func ParseJSONFromRequest

func ParseJSONFromRequest(r *http.Request, payload any) error

func ParseRequestPayload

func ParseRequestPayload[T any](r *http.Request, payload *T) error

func ParseStringURLParam

func ParseStringURLParam(name string, vars map[string]string) (string, error)

func ParseURLQuery

func ParseURLQuery(mapping map[string]any, values url.Values) error

func PathExists

func PathExists(path string) (bool, error)

func Ptr

func Ptr[T any](v T) *T

func RoundToNDecimals

func RoundToNDecimals(val float64, n int) float64

func RoundToNDecimals32

func RoundToNDecimals32(val float32, n int) float32

func WriteErrorInResponse

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

func WriteJSONInResponse

func WriteJSONInResponse(
	w http.ResponseWriter,
	status int,
	payload any,
	headers *map[string]string,
) error

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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