util

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendFilters

func AppendFilters(q *string, args *[]interface{}, queries *map[string]string, paging bool) error

AppendFilters according to the query map to the preoccupied database q. args has to be filled with the replacements for the SQL injection prevention done by the caller. The queries should already be filtered to only contain the relevant columns of the table. If not, this might result in a faulty q return.

func ConcatMultipleSlices

func ConcatMultipleSlices[T any](slices [][]T) []T

func DecodeJSONBody

func DecodeJSONBody(w http.ResponseWriter, r *http.Request, dst interface{}) *model.Response

Decode incoming JSON while doing extensive error handling.

func Format

func Format(i interface{})

Format formats a given interface into a format useable by a requesting client. This is mostly dedicated to prepending ids from the database.

func GetQueryMap

func GetQueryMap(r *http.Request, relevantQueries []string) *map[string]string

func GetRelevantQueriesByTarget

func GetRelevantQueriesByTarget(target string) []string

Decide on target which queries to look at in further logic.

func GetTotalPages

func GetTotalPages(totalItems, limit uint64) uint64

GetTotalPages calculates the total amount of pages.

func GetUintWithFallback

func GetUintWithFallback(l string, fallback uint64) (uint64, error)

TODO get this done less special with generics

Types

This section is empty.

Jump to

Keyboard shortcuts

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