utils

package
v0.0.0-...-80e094b Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package utils contains helper functions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateEtag

func GenerateEtag() (string, error)

GenerateEtag generates a random etag which is generated on every write action

func GenerateID

func GenerateID() string

GenerateID generates a string to be used as the resource ID

func GetValueFromVars

func GetValueFromVars(vars map[string]string, key string) (string, error)

GetValueFromVars returns a specified value from the supplied request vars.

func WriteErrorMessage

func WriteErrorMessage(w http.ResponseWriter, req *http.Request, status int, message string)

WriteErrorMessage logs an error and adds it to the response, along with the supplied status

func WriteJSON

func WriteJSON(w http.ResponseWriter, r *http.Request, data interface{})

WriteJSON writes the interface as a json string with status of 200.

func WriteJSONWithStatus

func WriteJSONWithStatus(w http.ResponseWriter, r *http.Request, data interface{}, status int)

WriteJSONWithStatus writes the interface as a json string with the supplied status.

func WriteResponseMessage

func WriteResponseMessage(w http.ResponseWriter, req *http.Request, status int, message string)

WriteResponseMessage writes a supplied message and status to the response, and logs an info message

Types

This section is empty.

Jump to

Keyboard shortcuts

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