rest

package
v0.0.0-...-abf6750 Latest Latest
Warning

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

Go to latest
Published: May 9, 2023 License: GPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = &core.Module{
	OnInit: func() {
		app := fiber.New(fiber.Config{
			DisableStartupMessage: true,
			ErrorHandler: func(c *fiber.Ctx, e error) error {
				if err, ok := e.(*fiber.Error); ok {
					return c.Status(err.Code).JSON(&fiber.Map{"data": nil, "error": err.Message})
				}

				logger.ErrorF("%s %s: %+v", c.Method(), c.Path(), e)
				return c.Status(fiber.StatusInternalServerError).JSON(&fiber.Map{"data": nil, "error": e.Error()})
			},
		})

		controller.New(app)

		if err := app.Listen(utils.Fmt(":%s", os.Getenv("API_PORT"))); err != nil {
			logger.FatalF("Não foi possível iniciar a API na porta %s: %v", os.Getenv("API_PORT"), err)
		}
	}}

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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