app

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2025 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Module(
	"vef:app",
	fx.Provide(New),
)

Functions

This section is empty.

Types

type App

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

App represents the VEF application server. It wraps a Fiber application and manages the HTTP server lifecycle.

func New

func New(params AppParams) (*App, error)

New creates a new VEF application instance with the provided dependencies. It initializes the Fiber application, applies middlewares, and registers Api routes. Returns an error if the application cannot be configured properly.

func (*App) Start

func (a *App) Start() <-chan error

Start starts the VEF application HTTP server. It returns a channel that will receive nil when the server is ready, or an error if the server fails to start. The server runs in a goroutine and can be stopped using the Stop method.

func (*App) Stop

func (a *App) Stop() error

Stop gracefully shuts down the VEF application server. It waits up to 30 seconds for active connections to close.

func (*App) Test

func (a *App) Test(req *http.Request, timeout ...time.Duration) (*http.Response, error)

Test sends an HTTP request to the application for testing purposes. This method is designed for unit and integration tests. The optional timeout parameter specifies the maximum duration to wait for a response. If no timeout is provided or timeout is zero, the default timeout is used.

type AppParams

type AppParams struct {
	fx.In

	Config        *config.AppConfig
	Middlewares   []Middleware `group:"vef:app:middlewares"`
	ApiEngine     api.Engine   `                            name:"vef:api:engine"`
	OpenApiEngine api.Engine   `                            name:"vef:openapi:engine"`
}

AppParams contains all dependencies required to create a VEF application. It is used with Uber FX dependency injection.

type CustomCtx

type CustomCtx struct {
	fiber.DefaultCtx
	// contains filtered or unexported fields
}

CustomCtx is a custom Fiber context that extends the default context with additional framework-specific functionality like logger, principal, and database access.

func (*CustomCtx) Db

func (c *CustomCtx) Db() orm.Db

Db returns the database connection for the current request.

func (*CustomCtx) Logger

func (c *CustomCtx) Logger() log.Logger

Logger returns the logger instance for the current request.

func (*CustomCtx) Principal

func (c *CustomCtx) Principal() *security.Principal

Principal returns the authenticated principal (user/system/app) for the current request.

func (*CustomCtx) SetDb

func (c *CustomCtx) SetDb(db orm.Db)

func (*CustomCtx) SetLogger

func (c *CustomCtx) SetLogger(logger log.Logger)

func (*CustomCtx) SetPrincipal

func (c *CustomCtx) SetPrincipal(principal *security.Principal)

type Middleware

type Middleware interface {
	// Name returns the name of the middleware.
	Name() string
	// Order returns the order of the middleware.
	Order() int
	// Apply applies the middleware to the router.
	Apply(router fiber.Router)
}

Middleware is a middleware for the app.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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