boom

package module
v0.0.0-...-0c9b40c Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2017 License: MIT Imports: 1 Imported by: 3

README

boom

like hapijs Boom but for Go

Status

Functions are being developed as we need them.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BadImplementation

func BadImplementation(err error) error

BadImplementation returns a 500 Internal Server Error.

func BadRequest

func BadRequest(message string, data map[string]interface{}) error

BadRequest returns 400 Bad Request.

func Forbidden

func Forbidden(message string) error

Forbidden returns 403 Forbidden.

func NotFound

func NotFound(message string) error

NotFound returns 404 Not Found.

func RangeNotSatisfiable

func RangeNotSatisfiable(message string, data map[string]interface{}) error

RangeNotSatisfiable returns 416 Range Not Satisfiable.

func Unauthorized

func Unauthorized(message string) error

Unauthorized returns 401 Unauthorized.

Types

type Error

type Error struct {
	Err        error
	IsServer   bool
	StatusCode int
	Output     Output
}

Error ..

func (Error) Error

func (e Error) Error() string

Error returns the internal error.

func (Error) MarshalJSON

func (e Error) MarshalJSON() ([]byte, error)

MarshalJSON implements Marshaler and returns only e.Output.

type Output

type Output struct {
	StatusCode int                    `json:"status_code"`
	Error      string                 `json:"error"`
	Message    string                 `json:"message"`
	Data       map[string]interface{} `json:"data"`
}

Output should be used to present a boom error to a user over HTTP.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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