fiberserver

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package fiberserver provides a lakta module for HTTP servers using Fiber.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Instance name
	Name string `koanf:"-"`

	// Host specifies the server's hostname or IP address to bind.
	Host string `koanf:"host"`

	// Port specifies the port number the server listens on.
	Port uint16 `koanf:"port"`

	// HealthPath defines the endpoint path for the health check.
	HealthPath string `koanf:"health_path"`

	// Defaults stores the base fiber.Config values that can be overridden by Raw or koanf configurations.
	Defaults *fiber.Config `code_only:"WithDefaults" koanf:"-"`

	// Routers defines a list of Router functions to configure routes for a Fiber application.
	Routers []Router `code_only:"WithRouter" koanf:"-"`

	// Raw passthrough for fiber.Config fields (app_name, read_timeout, etc.)
	Raw config.Passthrough[fiber.Config] `koanf:",remain"`
}

Config represents configuration for HTTP Fiber server Module

func NewConfig

func NewConfig(options ...Option) Config

NewConfig returns configuration with provided options based on defaults.

func NewDefaultConfig

func NewDefaultConfig() Config

NewDefaultConfig returns default configuration

func (*Config) AddrPort

func (c *Config) AddrPort() (netip.AddrPort, error)

AddrPort returns the parsed address and port for the server.

func (*Config) LoadFromKoanf

func (c *Config) LoadFromKoanf(k *koanf.Koanf, path string) error

LoadFromKoanf loads configuration from koanf instance at the given path. Preserves existing Raw entries as defaults, letting koanf values take precedence.

func (*Config) ToFiberConfig

func (c *Config) ToFiberConfig() fiber.Config

ToFiberConfig returns a fiber.Config with Defaults and Raw fields applied.

type Module

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

Module manages a Fiber HTTP server lifecycle.

func NewModule

func NewModule(options ...Option) *Module

NewModule creates a new Fiber HTTP server module with the given options.

func (*Module) ConfigPath

func (m *Module) ConfigPath() string

ConfigPath returns the koanf path for this module's configuration.

func (*Module) Init

func (m *Module) Init(ctx context.Context) error

Init loads configuration, creates the Fiber app, and registers middleware and routes.

func (*Module) LoadConfig

func (m *Module) LoadConfig(k *koanf.Koanf) error

LoadConfig loads configuration from koanf.

func (*Module) Name

func (m *Module) Name() string

Name returns the instance name.

func (*Module) Shutdown

func (m *Module) Shutdown(_ context.Context) error

Shutdown is a no-op; fiber handles its own shutdown via listener close.

func (*Module) Start

func (m *Module) Start(ctx context.Context) error

Start begins listening and serving HTTP requests.

type Option

type Option func(m *Config)

Option configures the Module.

func WithDefaults added in v0.0.2

func WithDefaults(cfg fiber.Config) Option

WithDefaults sets typed fiber.Config defaults that can be overridden by Raw/koanf values.

func WithHealthPath added in v0.0.2

func WithHealthPath(path string) Option

WithHealthPath sets the health check endpoint path.

func WithHost added in v0.0.2

func WithHost(host string) Option

WithHost sets the host address.

func WithName

func WithName(name string) Option

WithName sets the instance name for this module.

func WithPort added in v0.0.2

func WithPort(port uint16) Option

WithPort sets the port number.

func WithRouter

func WithRouter(router Router) Option

WithRouter adds router to the list of routers to be invoked (code-only).

type Router

type Router func(app *fiber.App)

Router registers routes on a fiber app.

Jump to

Keyboard shortcuts

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