jsonerr

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2023 License: MPL-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package jsonerr provides a simple way to return structured error information to the client using JSON encoding.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error

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

Error writes structured error information to w using JSON encoding. The given status code is used if it is non-zero, otherwise it is set to 500.

If err is nil it writes sets the status to 200 OK and writes:

{"code": "ok", "message": ""}

Types

This section is empty.

Jump to

Keyboard shortcuts

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