common

package
v0.6.0-next.7 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrWriting = errors.New("error writing error")

ErrWriting is returned when an ErrorWriter fails to write successfully.

View Source
var ErrWritten = errors.New("there was an error")

ErrWritten is returned when an error sent to an ErrorWriter has been written successfully.

Functions

func ErrorWriter

func ErrorWriter(w http.ResponseWriter, err error)

ErrorWriter writes an error in the JSON format to the http.ResponseWriter.

func ErrorWriter404

func ErrorWriter404(w http.ResponseWriter, name string, ok bool)

ErrorWriter404 writes an error in the JSON format to the with a 404 code.

func ErrorWriterCustom

func ErrorWriterCustom(w http.ResponseWriter, err error, code int)

ErrorWriterCustom writes an error in the JSON format to the http.ResponseWriter with a custom status code.

func GenerateID

func GenerateID(item interface{}) string

GenerateID takes an object, converts it to text (adds two 32 byte random strings) and returns a sha256 hash from it.

func RandomString

func RandomString() string

RandomString generates a random 32 byte random string.

func Recover

func Recover()

Recover allows you to recover from a writerError and to exit a function.

func Write

func Write(w http.ResponseWriter, i interface{})

Write writes the interface as a JSON to the ResponseWriter.

Types

This section is empty.

Jump to

Keyboard shortcuts

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