Documentation
¶
Index ¶
- Constants
- Variables
- func Adapt(value interface{}, targetType reflect.Type) (interface{}, error)
- func ApplyMiddleware(app *fiber.App, chain *MiddlewareChain)
- func ApplyPipes(value interface{}, pipes []PipeMeta) (interface{}, error)
- func AuthMiddleware(provider AuthProvider) fiber.Handler
- func CacheMiddleware(cache *Cache, expiration time.Duration) fiber.Handler
- func Controller(options ControllerOptions) func(c interface{}) interface{}
- func Delete(path string, options ...RouteOptions) func(interface{}, string, fiber.Handler)
- func Get(path string, options ...RouteOptions) func(interface{}, string, fiber.Handler)
- func GetEnv(key, defaultValue string) string
- func GetEnvBool(key string, defaultValue bool) bool
- func GetEnvInt(key string, defaultValue int) int
- func GlobalErrorHandler() fiber.Handler
- func Learn(model interface{}, prefix string, app *fiber.App)
- func LoadEnv()
- func LogMiddleware(logger *Logger) fiber.Handler
- func Module(options ModuleOptions) func(m interface{}) interface{}
- func Patch(path string, options ...RouteOptions) func(interface{}, string, fiber.Handler)
- func PermissionMiddleware(permissions ...Permission) fiber.Handler
- func Post(path string, options ...RouteOptions) func(interface{}, string, fiber.Handler)
- func Put(path string, options ...RouteOptions) func(interface{}, string, fiber.Handler)
- func RegisterAdapter(from, to reflect.Type, adapter AdapterFunc)
- func RegisterGuard(controller interface{}, guard Guard)
- func RegisterRoute(controller interface{}, opts RouteOptions, handler fiber.Handler)
- func RegisterRoutes(app *fiber.App)
- func RoleMiddleware(roles ...Role) fiber.Handler
- func SaveConfig(config *Config, path string) error
- func UseGuards(guards ...Guard) func(interface{}, string)
- func UseInterceptor(interceptor Interceptor, options InterceptorOptions) func(interface{}, string)
- func UsePipe(pipe Pipe, options PipeOptions) func(interface{}, string, int)
- func UsePipes(pipes ...PipeMeta) func(interface{}, string)
- func Validate(s interface{}) error
- func ValidateRequest(c *fiber.Ctx) error
- type AdapterFunc
- type AdapterRegistry
- type App
- type AppConfig
- type AuthConfig
- type AuthProvider
- type Cache
- type CacheConfig
- type CacheItem
- type Config
- type Container
- type ControllerMeta
- type ControllerOptions
- type DatabaseConfig
- type DatabaseManager
- type DatabaseProvider
- type EntityGenerator
- type Event
- type EventBus
- type EventHandler
- type Guard
- type Interceptor
- type InterceptorMeta
- type InterceptorOptions
- type JWTProvider
- type LogLevel
- type Logger
- func (l *Logger) Debug(format string, args ...interface{})
- func (l *Logger) Error(format string, args ...interface{})
- func (l *Logger) Fatal(format string, args ...interface{})
- func (l *Logger) Info(format string, args ...interface{})
- func (l *Logger) SetOutput(output *log.Logger)
- func (l *Logger) Warn(format string, args ...interface{})
- type MiddlewareChain
- type MiddlewareFunc
- type ModuleMeta
- type ModuleOptions
- type MongoDBProvider
- type MySQLProvider
- type Permission
- type Pipe
- func CustomPipe(validate func(interface{}) error) Pipe
- func DefaultPipe(defaultValue interface{}) Pipe
- func LengthPipe(min, max int) Pipe
- func ParseBoolPipe() Pipe
- func ParseIntPipe() Pipe
- func RangePipe(min, max float64) Pipe
- func RegexPipe(pattern string) Pipe
- func TrimPipe() Pipe
- func ValidationPipe() Pipe
- type PipeMeta
- type PipeOptions
- type Plugin
- type PluginRegistry
- type PluginState
- type PostgreSQLProvider
- type Role
- type RouteMeta
- type RouteOptions
Constants ¶
const ( GET = "GET" POST = "POST" PUT = "PUT" DELETE = "DELETE" PATCH = "PATCH" )
HTTP Methods
Variables ¶
var ( ErrPluginAlreadyRegistered = fiber.NewError(fiber.StatusConflict, "plugin already registered") ErrPluginNotFound = fiber.NewError(fiber.StatusNotFound, "plugin not found") )
Plugin errors
var (
ErrInvalidTarget = fiber.NewError(fiber.StatusInternalServerError, "invalid injection target")
)
Inject errors
Functions ¶
func ApplyMiddleware ¶
func ApplyMiddleware(app *fiber.App, chain *MiddlewareChain)
ApplyMiddleware applies middleware to a fiber app
func ApplyPipes ¶
ApplyPipes applies pipes to a value
func AuthMiddleware ¶
func AuthMiddleware(provider AuthProvider) fiber.Handler
AuthMiddleware creates an authentication middleware
func CacheMiddleware ¶
CacheMiddleware creates a middleware that caches responses
func Controller ¶
func Controller(options ControllerOptions) func(c interface{}) interface{}
Controller decorator for class
func Delete ¶
func Delete(path string, options ...RouteOptions) func(interface{}, string, fiber.Handler)
Delete registers a DELETE route
func Get ¶
func Get(path string, options ...RouteOptions) func(interface{}, string, fiber.Handler)
Get registers a GET route
func GetEnvBool ¶
GetEnvBool returns an environment variable as a boolean or a default value
func GlobalErrorHandler ¶
GlobalErrorHandler creates a global error handling middleware
func LogMiddleware ¶
LogMiddleware creates a logging middleware
func Module ¶
func Module(options ModuleOptions) func(m interface{}) interface{}
Module decorator for class
func Patch ¶
func Patch(path string, options ...RouteOptions) func(interface{}, string, fiber.Handler)
Patch registers a PATCH route
func PermissionMiddleware ¶
func PermissionMiddleware(permissions ...Permission) fiber.Handler
PermissionMiddleware creates a permission-based authorization middleware
func Post ¶
func Post(path string, options ...RouteOptions) func(interface{}, string, fiber.Handler)
Post registers a POST route
func Put ¶
func Put(path string, options ...RouteOptions) func(interface{}, string, fiber.Handler)
Put registers a PUT route
func RegisterAdapter ¶
func RegisterAdapter(from, to reflect.Type, adapter AdapterFunc)
RegisterAdapter registers a global adapter
func RegisterGuard ¶
func RegisterGuard(controller interface{}, guard Guard)
RegisterGuard adds a guard to the controller's metadata
func RegisterRoute ¶
func RegisterRoute(controller interface{}, opts RouteOptions, handler fiber.Handler)
RegisterRoute adds a new route to the controller's metadata
func RegisterRoutes ¶
RegisterRoutes registers all controller routes
func RoleMiddleware ¶
RoleMiddleware creates a role-based authorization middleware
func SaveConfig ¶
SaveConfig saves the configuration to a file
func UseInterceptor ¶
func UseInterceptor(interceptor Interceptor, options InterceptorOptions) func(interface{}, string)
UseInterceptor decorator for method
func UsePipe ¶
func UsePipe(pipe Pipe, options PipeOptions) func(interface{}, string, int)
UsePipe decorator for method parameter
func ValidateRequest ¶
Types ¶
type AdapterFunc ¶
type AdapterFunc func(interface{}) (interface{}, error)
AdapterFunc is a function that can adapt one type to another
type AdapterRegistry ¶
type AdapterRegistry struct {
// contains filtered or unexported fields
}
AdapterRegistry stores registered adapters
func NewAdapterRegistry ¶
func NewAdapterRegistry() *AdapterRegistry
NewAdapterRegistry creates a new adapter registry
func (*AdapterRegistry) Adapt ¶
func (r *AdapterRegistry) Adapt(value interface{}, targetType reflect.Type) (interface{}, error)
Adapt attempts to adapt a value to the target type
func (*AdapterRegistry) GetAdapter ¶
func (r *AdapterRegistry) GetAdapter(from, to reflect.Type) (AdapterFunc, bool)
GetAdapter retrieves an adapter for the given types
func (*AdapterRegistry) RegisterAdapter ¶
func (r *AdapterRegistry) RegisterAdapter(from, to reflect.Type, adapter AdapterFunc)
RegisterAdapter registers a new adapter
type AppConfig ¶
type AppConfig struct {
Port int `json:"port"`
Env string `json:"env"`
LogLevel string `json:"logLevel"`
}
AppConfig represents the application configuration
type AuthConfig ¶
type AuthConfig struct {
Secret string `json:"secret"`
}
AuthConfig represents the authentication configuration
type AuthProvider ¶
AuthProvider defines the interface for authentication providers
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a thread-safe in-memory cache
type CacheConfig ¶
CacheConfig represents the cache configuration
type Config ¶
type Config struct {
App AppConfig `json:"app"`
Database DatabaseConfig `json:"database"`
Auth AuthConfig `json:"auth"`
Cache CacheConfig `json:"cache"`
}
Config represents the application configuration
func LoadConfig ¶
LoadConfig loads the configuration from a file
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
Container manages dependencies
type ControllerMeta ¶
type ControllerMeta struct {
Instance interface{}
Path string
Guards []Guard
Version string
Routes []RouteMeta
}
ControllerMeta stores controller metadata
func GetControllers ¶
func GetControllers() []ControllerMeta
GetControllers returns all registered controllers
type ControllerOptions ¶
ControllerOptions defines controller configuration
type DatabaseConfig ¶
type DatabaseConfig struct {
Driver string `json:"driver"`
Host string `json:"host"`
Port int `json:"port"`
User string `json:"user"`
Password string `json:"password"`
Database string `json:"database"`
}
DatabaseConfig represents the database configuration
type DatabaseManager ¶
type DatabaseManager struct {
// contains filtered or unexported fields
}
DatabaseManager manages database connections
func NewDatabaseManager ¶
func NewDatabaseManager() *DatabaseManager
NewDatabaseManager creates a new database manager
func (*DatabaseManager) ConnectAll ¶
func (m *DatabaseManager) ConnectAll() error
ConnectAll connects all registered providers
func (*DatabaseManager) DisconnectAll ¶
func (m *DatabaseManager) DisconnectAll() error
DisconnectAll disconnects all registered providers
func (*DatabaseManager) GetProvider ¶
func (m *DatabaseManager) GetProvider(name string) (DatabaseProvider, error)
GetProvider returns a database provider
func (*DatabaseManager) RegisterProvider ¶
func (m *DatabaseManager) RegisterProvider(name string, provider DatabaseProvider) error
RegisterProvider registers a database provider
type DatabaseProvider ¶
DatabaseProvider defines the interface for database providers
type EntityGenerator ¶
type EntityGenerator struct {
// contains filtered or unexported fields
}
EntityGenerator watches schema files and generates entities
func NewEntityGenerator ¶
func NewEntityGenerator() (*EntityGenerator, error)
NewEntityGenerator creates a new entity generator
func (*EntityGenerator) Start ¶
func (g *EntityGenerator) Start() error
Start starts watching for schema changes
func (*EntityGenerator) Stop ¶
func (g *EntityGenerator) Stop()
Stop stops watching for schema changes
type EventBus ¶
type EventBus struct {
// contains filtered or unexported fields
}
EventBus manages event subscriptions and publishing
func (*EventBus) Subscribe ¶
func (b *EventBus) Subscribe(eventName string, handler EventHandler) error
Subscribe subscribes to an event
func (*EventBus) Unsubscribe ¶
func (b *EventBus) Unsubscribe(eventName string, handler EventHandler) error
Unsubscribe removes a handler from an event
type EventHandler ¶
EventHandler is a function that handles an event
type Interceptor ¶
Interceptor is a function that can intercept requests
func LoggingInterceptor ¶
func LoggingInterceptor() Interceptor
LoggingInterceptor example interceptor
type InterceptorMeta ¶
type InterceptorMeta struct {
Path string
Interceptor Interceptor
}
InterceptorMeta stores interceptor metadata
func GetInterceptors ¶
func GetInterceptors() []InterceptorMeta
GetInterceptors returns all registered interceptors
type InterceptorOptions ¶
type InterceptorOptions struct {
Path string
}
InterceptorOptions defines interceptor configuration
type JWTProvider ¶
type JWTProvider struct {
Secret string
}
JWTProvider implements JWT authentication
func NewJWTProvider ¶
func NewJWTProvider(secret string) *JWTProvider
NewJWTProvider creates a new JWT provider
func (*JWTProvider) Authenticate ¶
func (p *JWTProvider) Authenticate(ctx *fiber.Ctx) (interface{}, error)
Authenticate implements JWT authentication
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is a configurable logger
type MiddlewareChain ¶
type MiddlewareChain struct {
// contains filtered or unexported fields
}
MiddlewareChain represents a chain of middleware functions
func Compose ¶
func Compose(middlewares ...MiddlewareFunc) *MiddlewareChain
Compose creates a new middleware chain from multiple middleware functions
func NewMiddlewareChain ¶
func NewMiddlewareChain() *MiddlewareChain
NewMiddlewareChain creates a new middleware chain
func (*MiddlewareChain) Then ¶
func (c *MiddlewareChain) Then(handler fiber.Handler) fiber.Handler
Then executes the middleware chain
func (*MiddlewareChain) Use ¶
func (c *MiddlewareChain) Use(middleware MiddlewareFunc)
Use adds a middleware to the chain
type MiddlewareFunc ¶
MiddlewareFunc is a function that can be used as middleware
func CreateMiddleware ¶
func CreateMiddleware(fn func(*fiber.Ctx) error) MiddlewareFunc
CreateMiddleware creates a new middleware function
type ModuleMeta ¶
type ModuleMeta struct {
Instance interface{}
Imports []interface{}
Controllers []interface{}
Providers []interface{}
Exports []interface{}
}
ModuleMeta stores module metadata
func GetModule ¶
func GetModule(moduleType interface{}) (ModuleMeta, error)
GetModule returns a module by type
type ModuleOptions ¶
type ModuleOptions struct {
Imports []interface{}
Controllers []interface{}
Providers []interface{}
Exports []interface{}
}
ModuleOptions defines module configuration
type MongoDBProvider ¶
type MongoDBProvider struct {
URI string
Database string
// contains filtered or unexported fields
}
MongoDBProvider implements MongoDB database provider
func NewMongoDBProvider ¶
func NewMongoDBProvider(uri, database string) *MongoDBProvider
NewMongoDBProvider creates a new MongoDB provider
func (*MongoDBProvider) Connect ¶
func (p *MongoDBProvider) Connect() error
Connect implements MongoDB connection
func (*MongoDBProvider) Disconnect ¶
func (p *MongoDBProvider) Disconnect() error
Disconnect implements MongoDB disconnection
func (*MongoDBProvider) GetCollection ¶
func (p *MongoDBProvider) GetCollection(name string) *mongo.Collection
GetCollection returns a MongoDB collection
func (*MongoDBProvider) GetDB ¶
func (p *MongoDBProvider) GetDB() interface{}
GetDB returns the MongoDB database instance
type MySQLProvider ¶
type MySQLProvider struct {
Host string
Port int
User string
Password string
Database string
// contains filtered or unexported fields
}
MySQLProvider implements MySQL database provider
func NewMySQLProvider ¶
func NewMySQLProvider(host string, port int, user, password, database string) *MySQLProvider
NewMySQLProvider creates a new MySQL provider
func (*MySQLProvider) Connect ¶
func (p *MySQLProvider) Connect() error
Connect implements MySQL connection
func (*MySQLProvider) Disconnect ¶
func (p *MySQLProvider) Disconnect() error
Disconnect implements MySQL disconnection
func (*MySQLProvider) GetDB ¶
func (p *MySQLProvider) GetDB() *sql.DB
GetDB returns the database connection
type Pipe ¶
type Pipe func(interface{}) (interface{}, error)
Pipe is a function that can transform or validate data
func CustomPipe ¶
CustomPipe creates a custom pipe with a validation function
func DefaultPipe ¶
func DefaultPipe(defaultValue interface{}) Pipe
DefaultPipe provides a default value if the input is nil
type PipeOptions ¶
PipeOptions defines pipe configuration
type Plugin ¶
type Plugin interface {
// Register is called when the plugin is initialized
Register(app *App) error
// Start is called when the plugin is started
Start() error
// Stop is called when the plugin is stopped
Stop() error
// GetName returns the name of the plugin
GetName() string
// GetVersion returns the version of the plugin
GetVersion() string
// GetState returns the current state of the plugin
GetState() PluginState
}
Plugin interface defines the contract for all plugins
type PluginRegistry ¶
type PluginRegistry struct {
// contains filtered or unexported fields
}
PluginRegistry manages all registered plugins
func NewPluginRegistry ¶
func NewPluginRegistry() *PluginRegistry
NewPluginRegistry creates a new plugin registry
func (*PluginRegistry) GetPlugin ¶
func (r *PluginRegistry) GetPlugin(name string) (Plugin, error)
GetPlugin retrieves a plugin by name
func (*PluginRegistry) InitializePlugins ¶
func (r *PluginRegistry) InitializePlugins(app *App) error
InitializePlugins initializes all registered plugins
func (*PluginRegistry) RegisterPlugin ¶
func (r *PluginRegistry) RegisterPlugin(plugin Plugin) error
RegisterPlugin adds a new plugin to the registry
func (*PluginRegistry) StartPlugins ¶
func (r *PluginRegistry) StartPlugins() error
StartPlugins starts all registered plugins
func (*PluginRegistry) StopPlugins ¶
func (r *PluginRegistry) StopPlugins() error
StopPlugins stops all registered plugins
type PluginState ¶
type PluginState int
PluginState represents the state of a plugin
const ( PluginStateUninitialized PluginState = iota PluginStateInitialized PluginStateStarted PluginStateStopped )
type PostgreSQLProvider ¶
type PostgreSQLProvider struct {
Host string
Port int
User string
Password string
Database string
// contains filtered or unexported fields
}
PostgreSQLProvider implements PostgreSQL database provider
func NewPostgreSQLProvider ¶
func NewPostgreSQLProvider(host string, port int, user, password, database string) *PostgreSQLProvider
NewPostgreSQLProvider creates a new PostgreSQL provider
func (*PostgreSQLProvider) Connect ¶
func (p *PostgreSQLProvider) Connect() error
Connect implements PostgreSQL connection
func (*PostgreSQLProvider) Disconnect ¶
func (p *PostgreSQLProvider) Disconnect() error
Disconnect implements PostgreSQL disconnection
func (*PostgreSQLProvider) GetDB ¶
func (p *PostgreSQLProvider) GetDB() *sql.DB
GetDB returns the database connection
type RouteOptions ¶
RouteOptions defines route configuration