fiberparser

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: May 20, 2022 License: AGPL-3.0 Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseAndValidate

func ParseAndValidate(fiberCtx *fiber.Ctx, s interface{}) error

ParseAndValidate is a wrapper function for ParseBody and customvalidator.ValidateJSON

func ParseBody

func ParseBody(fiberCtx *fiber.Ctx, s interface{}) error

ParseBody parses a pointer to a struct with fiber's body parse.

It returns custom errors that are not present in the fiber implementation.

func RegisterErrorHandler

func RegisterErrorHandler(ctx *fiber.Ctx, err error) error

RegisterErrorHandler registers a new Fiber Error Handler. It needs to be used with the Panic MW

It overrides the REST error response when the application has an unexpected error (to avoid information disclosure to the client).

That's why it needs to be used when the panic MW is active to avoid information disclosure to the client.

Instead, it redirects the client to home.

(More info on: https://docs.gofiber.io/api/middleware/recover and https://docs.gofiber.io/guide/error-handling)

func ValidateJSON

func ValidateJSON(s interface{}) []error

ValidateJSON accepts a struct and validates it according to its model's tags. It returns a slice of errors.

When iterating there's no need to check if errors are nil, because it doesn't return empty errors.

Types

This section is empty.

Jump to

Keyboard shortcuts

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