Documentation ¶
Index ¶
- func DummyHandler(w http.ResponseWriter, r *http.Request)
- func GetOrCreateID(id string) string
- func IntroCheck(h defs.MWBaser, w http.ResponseWriter, r *http.Request) bool
- func MapKeys[T comparable, S any](m map[T]S) []T
- func Must[T any](val T, err error) T
- func WriteState(w http.ResponseWriter, log *slog.Logger, httpState int)
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 ¶
GetOrCreateID generates a new uuid, if the given id is empty, otherwise the given id is returned.
func IntroCheck ¶
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 ¶
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.