handler

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidVIN = NewError(400, "vin.is_not_valid")
)

Functions

This section is empty.

Types

type Error

type Error interface {
	error
	Status() int
}

Error represents a handler error. It provides methods for a HTTP status code and embeds the built-in error interface.

func NewError

func NewError(code int, message string) Error

NewError creates new error instance.

type Handler

type Handler func(w http.ResponseWriter, r *http.Request) error

The Handler helps to handle errors in one place.

func (Handler) ServeHTTP

func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP allows our Handler type to satisfy http.Handler.

type StatusError

type StatusError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

StatusError represents error with http status code.

func (StatusError) Error

func (se StatusError) Error() string

Error allows StatusError to satisfy the error interface.

func (StatusError) Status

func (se StatusError) Status() int

Status returns our HTTP status code.

Jump to

Keyboard shortcuts

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