http

package
v0.0.0-...-1c6c14e Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Module(
	"http",
	fx.Decorate(func(log *zap.Logger) *zap.Logger {
		return log.Named("http")
	}),
	fx.Provide(New),
	fx.Invoke(func(lc fx.Lifecycle, cfg Config, app *fiber.App, logger *zap.Logger) {
		lc.Append(fx.Hook{
			OnStart: func(ctx context.Context) error {
				go func() {
					_ = app.Listen(cfg.Address)
				}()
				logger.Info("server started")

				return nil
			},
			OnStop: func(ctx context.Context) error {
				logger.Warn("shutting down server")
				_ = app.ShutdownWithContext(ctx)
				return nil
			},
		})
	}),
)

Functions

func New

func New(config Config, option Options, logger *zap.Logger) (*fiber.App, error)

func NewJSONErrorHandler

func NewJSONErrorHandler(logger *zap.Logger) fiber.ErrorHandler

func NewViewsErrorHandler

func NewViewsErrorHandler(logger *zap.Logger, template string, layouts ...string) fiber.ErrorHandler

Types

type Config

type Config struct {
	Address     string
	ProxyHeader string
	Proxies     []string
}

type Error

type Error struct {
	Message string `json:"message"`
	Details any    `json:"details,omitempty"`
}

type ErrorResponse

type ErrorResponse struct {
	Error Error `json:"error"`
}

type JSONErrorResponse

type JSONErrorResponse struct {
	Error struct {
		Message string `json:"message"` // Message
		Code    int    `json:"code"`    // Code
	}
}

type Options

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

func (*Options) WithErrorHandler

func (o *Options) WithErrorHandler(handler fiber.ErrorHandler) *Options

func (*Options) WithGetOnly

func (o *Options) WithGetOnly() *Options

func (*Options) WithViews

func (o *Options) WithViews(views fiber.Views) *Options

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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