Documentation ¶
Index ¶
- Variables
- func ErrorWriter(w http.ResponseWriter, err error)
- func ErrorWriter404(w http.ResponseWriter, name string, ok bool)
- func ErrorWriterCustom(w http.ResponseWriter, err error, code int)
- func GenerateID(item interface{}) string
- func RandomString() string
- func Recover()
- func Write(w http.ResponseWriter, i interface{})
Constants ¶
This section is empty.
Variables ¶
var ErrWriting = errors.New("error writing error")
ErrWriting is returned when an ErrorWriter fails to write successfully.
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.