httperrors

package
v0.0.0-...-d79ce87 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Now = time.Now

Now returns the current time

Functions

func Marshal

func Marshal(r *http.Request, w http.ResponseWriter, err error) error

Marshal marshals `err` to the HTTP response writer

func Unmarshal

func Unmarshal(w *http.Response) error

Types

type Status

type Status struct {
	// contains filtered or unexported fields
}

Status represents an HTTP status code, message, and details. It is immutable and should be created with New, or Newf.

func New

func New(code int, msg string) *Status

New returns a Status representing c and msg.

func Newf

func Newf(code int, format string, a ...interface{}) *Status

Newf returns New(c, fmt.Sprintf(format, a...)).

func Pack

func Pack(err error) *Status

Pack returns a Status representing err if it was produced from an `*errors.Error` struct.

func (*Status) Code

func (s *Status) Code() int

Code returns the status code contained in s.

func (*Status) Err

func (s *Status) Err() error

Err returns an immutable error representing s; returns nil if s.Code() is OK.

func (*Status) Error

func (se *Status) Error() string

func (*Status) HTTPStatus

func (se *Status) HTTPStatus() *Status

func (*Status) Message

func (s *Status) Message() string

Message returns the message contained in s.

Jump to

Keyboard shortcuts

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