web

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Earliest = di.Earliest
	Earlier  = di.Earlier
	Normal   = di.Normal
	Later    = di.Later
	Latest   = di.Latest
)
View Source
const DefaultSpaDistPath = "web/dist"

Variables

View Source
var HandlersGroupName = "us.handlers"

Functions

func Module

func Module(extends ...di.Node) di.Node

func NewFiberApp

func NewFiberApp(config FiberConfig) *fiber.App

func NewFiberAppWithOptions added in v1.9.2

func NewFiberAppWithOptions(config FiberConfig, opts ...FiberAppOption) *fiber.App

func NopOtelMiddleware

func NopOtelMiddleware() di.Node

func ParseBodyLimit added in v1.9.2

func ParseBodyLimit(v string) (int, error)

func ParseTLSMinVersion added in v1.9.2

func ParseTLSMinVersion(v string) (uint16, error)

func Priority

func Priority(value PriorityLevel) di.Option

func RegisterFiberApp

func RegisterFiberApp(lc fx.Lifecycle, app *fiber.App, logger *zap.Logger, config Config)

func RunFiberApp added in v1.5.0

func RunFiberApp() di.Node

func SetupHandlers

func SetupHandlers(in setupHandlersIn)

func UseBuildInfo

func UseBuildInfo(opts ...BuildInfoOption) di.Node

func UseOtel added in v1.3.0

func UseOtel() di.Node

func UseSpa

func UseSpa(opts ...SpaOption) di.Node

func UseSwagger

func UseSwagger(opts ...SwaggerOption) di.Node

Types

type BuildInfoHandler

type BuildInfoHandler = buildinfo.Handler

func NewBuildInfoHandler

func NewBuildInfoHandler(opts ...BuildInfoOption) *BuildInfoHandler

type BuildInfoOption

type BuildInfoOption = buildinfo.Option

func WithDefaultPath

func WithDefaultPath(path ...string) BuildInfoOption

type Config

type Config struct {
	Server ServerConfig `mapstructure:"server"`
	Listen ListenConfig `mapstructure:"listen"`
	TLS    TLSConfig    `mapstructure:"tls"`
}

type DateQuery

type DateQuery struct {
	FromDate time.Time `query:"from_date" json:"from_date"`
	ToDate   time.Time `query:"to_date" json:"to_date"`
}

type Error

type Error struct {
	Error     ErrorDetail `json:"error"`
	RequestID string      `json:"request_id"`
}

type ErrorDetail

type ErrorDetail struct {
	Code    string   `json:"code"`
	Message string   `json:"message"`
	Details []string `json:"details"`
}

type FiberAppConfig added in v1.9.2

type FiberAppConfig struct {
	ServerHeader       string        `mapstructure:"server_header"`
	BodyLimit          string        `mapstructure:"body_limit" default:"4MiB"`
	ReadTimeout        time.Duration `mapstructure:"read_timeout" default:"10s"`
	WriteTimeout       time.Duration `mapstructure:"write_timeout" default:"10s"`
	IdleTimeout        time.Duration `mapstructure:"idle_timeout" default:"60s"`
	ReadBufferSize     int           `mapstructure:"read_buffer_size" default:"4096"`
	WriteBufferSize    int           `mapstructure:"write_buffer_size" default:"4096"`
	DisableKeepalive   bool          `mapstructure:"disable_keepalive" default:"false"`
	EnableIPValidation bool          `mapstructure:"enable_ip_validation" default:"true"`
}

type FiberAppOption added in v1.9.2

type FiberAppOption interface {
	// contains filtered or unexported methods
}

func WithName added in v1.9.2

func WithName(name string) FiberAppOption

type FiberConfig

type FiberConfig struct {
	App           FiberAppConfig   `mapstructure:"app"`
	Proxy         FiberProxyConfig `mapstructure:"proxy"`
	CaseSensitive bool             `mapstructure:"case_sensitive" default:"false"`
	StrictRouting bool             `mapstructure:"strict_routing" default:"false"`
}

type FiberProxyConfig added in v1.9.2

type FiberProxyConfig struct {
	TrustProxy       bool                   `mapstructure:"trust_proxy" default:"false"`
	ProxyHeader      string                 `mapstructure:"proxy_header"`
	TrustProxyConfig fiber.TrustProxyConfig `mapstructure:"trust_proxy_config"`
}

type Handler

type Handler interface {
	Handle(r fiber.Router)
}

type ListenConfig added in v1.9.2

type ListenConfig struct {
	ListenerNetwork       string        `mapstructure:"listener_network" default:"tcp"`
	ShutdownTimeout       time.Duration `mapstructure:"shutdown_timeout" default:"10s"`
	DisableStartupMessage bool          `mapstructure:"disable_startup_message" default:"false"`
	EnablePrefork         bool          `mapstructure:"enable_prefork" default:"false"`
	EnablePrintRoutes     bool          `mapstructure:"enable_print_routes" default:"false"`
}

type MockHandler added in v1.2.0

type MockHandler struct {
	mock.Mock
}

MockHandler is an autogenerated mock type for the Handler type

func NewMockHandler added in v1.2.0

func NewMockHandler(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockHandler

NewMockHandler creates a new instance of MockHandler. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockHandler) EXPECT added in v1.2.0

func (_m *MockHandler) EXPECT() *MockHandler_Expecter

func (*MockHandler) Handle added in v1.2.0

func (_mock *MockHandler) Handle(r fiber.Router)

Handle provides a mock function for the type MockHandler

type MockHandler_Expecter added in v1.2.0

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

func (*MockHandler_Expecter) Handle added in v1.2.0

func (_e *MockHandler_Expecter) Handle(r interface{}) *MockHandler_Handle_Call

Handle is a helper method to define mock.On call

  • r fiber.Router

type MockHandler_Handle_Call added in v1.2.0

type MockHandler_Handle_Call struct {
	*mock.Call
}

MockHandler_Handle_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Handle'

func (*MockHandler_Handle_Call) Return added in v1.2.0

func (*MockHandler_Handle_Call) Run added in v1.2.0

func (*MockHandler_Handle_Call) RunAndReturn added in v1.2.0

func (_c *MockHandler_Handle_Call) RunAndReturn(run func(r fiber.Router)) *MockHandler_Handle_Call

type OtelMiddleware

type OtelMiddleware struct {
	otel.Telemetry
	// contains filtered or unexported fields
}

func NewOtelMiddleware

func NewOtelMiddleware(config otel.Config, lp *otel.LoggerProvider) *OtelMiddleware

func (*OtelMiddleware) Handle

func (h *OtelMiddleware) Handle(r fiber.Router)

type PageQuery

type PageQuery struct {
	Page  int `query:"page" json:"page"`
	Limit int `query:"limit" json:"limit"`
}

type PagedMeta

type PagedMeta struct {
	Page       int  `json:"page,omitempty"`
	Limit      int  `json:"limit,omitempty"`
	TotalItems int  `json:"total_items,omitempty"`
	TotalPages int  `json:"total_pages,omitempty"`
	HasNext    bool `json:"has_next,omitempty"`
	HasPrev    bool `json:"has_prev,omitempty"`
}

type PagedResponse

type PagedResponse struct {
	Data any       `json:"data,omitempty"`
	Meta PagedMeta `json:"meta"`
}

type PriorityLevel

type PriorityLevel = di.PriorityLevel

func Between

func Between(lower, upper PriorityLevel) PriorityLevel

type Response

type Response struct {
	Data any `json:"data,omitempty"`
	Meta any `json:"meta,omitempty"`
}

type ServerConfig added in v1.9.2

type ServerConfig struct {
	Host string `mapstructure:"host" default:"localhost"`
	Port int    `mapstructure:"port" default:"8080"`
}

type SpaMiddleware

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

func NewSpaMiddleware

func NewSpaMiddleware(assets *embed.FS, log *zap.Logger) (*SpaMiddleware, error)

func NewSpaMiddlewareWithOptions added in v1.2.0

func NewSpaMiddlewareWithOptions(opts ...SpaOption) (*SpaMiddleware, error)

func (*SpaMiddleware) Handle

func (s *SpaMiddleware) Handle(r fiber.Router)

type SpaOption added in v1.2.0

type SpaOption func(*spaOptions)

func WithSpaAssets added in v1.2.0

func WithSpaAssets(assets *embed.FS) SpaOption

func WithSpaDistPath added in v1.2.0

func WithSpaDistPath(path string) SpaOption

func WithSpaLogger added in v1.2.0

func WithSpaLogger(log *zap.Logger) SpaOption

type SwaggerHandler

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

func NewSwaggerHandler

func NewSwaggerHandler(config Config) (*SwaggerHandler, error)

func NewSwaggerHandlerWithOptions added in v1.2.0

func NewSwaggerHandlerWithOptions(opts ...SwaggerOption) (*SwaggerHandler, error)

func (*SwaggerHandler) Handle

func (h *SwaggerHandler) Handle(r fiber.Router)

type SwaggerOption added in v1.2.0

type SwaggerOption func(*swaggerOptions)

func WithSwaggerConfig added in v1.2.0

func WithSwaggerConfig(config Config) SwaggerOption

func WithSwaggerPath added in v1.2.0

func WithSwaggerPath(path string) SwaggerOption

type TLSConfig added in v1.9.2

type TLSConfig struct {
	CertFile       string `mapstructure:"cert_file"`
	CertKeyFile    string `mapstructure:"cert_key_file"`
	CertClientFile string `mapstructure:"cert_client_file"`
	TLSMinVersion  string `mapstructure:"tls_min_version" default:"1.2"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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