util

package
v0.0.0-...-4f5bba3 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DummyHandler

func DummyHandler(w http.ResponseWriter, r *http.Request)

DummyHandler is a handler used for internal testing. It simply writes the text "dummy" to the given http.ResponseWriter.

func GetOrCreateID

func GetOrCreateID(id string) string

GetOrCreateID generates a new uuid, if the given id is empty, otherwise the given id is returned.

func IntroCheck

func IntroCheck(h defs.MWBaser, w http.ResponseWriter, r *http.Request) bool

IntroCheck is used to facilitate the introductory check in each handler for the basic requirements. It manages the corresponding logging operations and can be used as follows:

if !util.IntroCheck(h, w, r) {
    return
}

func MapKeys

func MapKeys[T comparable, S any](m map[T]S) []T

MapKeys gets the keys of the given map and saves them into a slice. There is not to expect a particular order of the elements of that slice. A nil map will produce a nil result, an empty map produces an empty slice.

func Must

func Must[T any](val T, err error) T

Must exits the program if the given pair of function return and error contains an non-nil error value, otherwise the function return value val is returned.

func WriteState

func WriteState(w http.ResponseWriter, log *slog.Logger, httpState int)

WriteState sets the specified HTTP response code and writes the code specific text as body. If an error occurs on writing to the client, it is logged to the specified logging instance. It is intended to give error feedback to clients.

Types

This section is empty.

Jump to

Keyboard shortcuts

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