fiber

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2022 License: BSD-3-Clause Imports: 8 Imported by: 0

README

Fiber (webserver)

Setting up the preconfigured webserver:

app := fx.New(
	env.Module,
	logrus.Module,
	metrics.Module,
	fiber.Module,
)
app.Run()

It will integrate logging, metrics and basic error handling into your webserver app.

Error handling

func useFiber(app *fiber.App) {
	app.Get("/path", func(c *fiber.Ctx) error {
		// whenever you return a `fiber.Error`:
		// - the status code will be set automatically
		// - the error will be logged
		// - and the error string wil be returned in the response body
		return fiber.NewFiberError(errors.New("your error"), fiber.StatusBadRequest)
	})
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Options(
	fx.Provide(
		newFiber,
	),
	fx.Invoke(
		useFiber,
	),
)

Functions

This section is empty.

Types

type Error

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

func NewError

func NewError(err error, statusCode int) *Error

func (*Error) Error

func (e *Error) Error() string

func (*Error) StatusCode

func (e *Error) StatusCode() int

Jump to

Keyboard shortcuts

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