fiber_errhandler

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 29, 2020 License: MIT Imports: 6 Imported by: 0

README

fiber-errhandler

An Error handling middleware for fiber.

Install

go get -u github.com/gofiber/fiber
go get -u github.com/hendratommy/fiber-errhandler

Example

See example

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(config ...Config) func(*fiber.Ctx)

New ...

func NewHttpError

func NewHttpError(statusCode int, message string, data interface{}) *httpError

Types

type Config

type Config struct {
	// Filter defines a function to skip middleware.
	// Optional. Default: nil
	Filter func(*fiber.Ctx) bool
	// Custom error handler
	// Optional. Default: nil
	Handler func(*fiber.Ctx, error, func(...interface{}))
	// Log all errors to output
	// Optional. Default: false
	Log bool
	// Output is a writer where logs are written
	// Default: os.Stderr
	Output io.Writer
	// Use c.Render for content-type html
	// Optional. Default: false
	UseTemplate bool
}

Config ...

type HTTPError

type HTTPError interface {
	// HTTP Status code to respond with.
	// Optional. Default: 500
	StatusCode() int
	// Error message
	// Optional. Default: ""
	Message() string
	// Data to respond with or to bind to views.
	// Optional. Default: nil
	Data() interface{}
	Error() string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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