reserr

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package reserr writes useful JSON message on HTTP error.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InvalidPath

func InvalidPath(w http.ResponseWriter, r *http.Request)

func NotImplemented

func NotImplemented(w http.ResponseWriter, r *http.Request)

func Write

func Write(w http.ResponseWriter, r *http.Request, statusCode int, a ...any)

Types

type ResErr

type ResErr string

func New

func New(docURL string) ResErr

New creates a ResErr structure.

func (ResErr) InvalidPath

func (resErr ResErr) InvalidPath(w http.ResponseWriter, r *http.Request)

func (ResErr) NotImplemented

func (resErr ResErr) NotImplemented(w http.ResponseWriter, r *http.Request)

func (ResErr) SafeWrite

func (resErr ResErr) SafeWrite(w http.ResponseWriter, r *http.Request, statusCode int, messages ...any)

SafeWrite is a safe alternative to Write, may be slower despite the easyjson generated code. SafeWrite concatenates all messages in "error" field.

func (ResErr) Write

func (resErr ResErr) Write(w http.ResponseWriter, r *http.Request, statusCode int, messages ...any)

Write is a fast pretty-JSON marshaler dedicated to the HTTP error response. Write extends the JSON content when more than two messages are provided.

Jump to

Keyboard shortcuts

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