app

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

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

App orchestrates DI, HTTP, dispatching, and scheduling into a single entrypoint.

func New

func New() *App

New creates a new App with default components.

func (*App) Build

func (a *App) Build() (*di.Container, error)

Build constructs the DI container and registers all handlers.

func (*App) Configure

func (a *App) Configure(fn func(*srv.Server)) *App

Configure allows direct customization of the underlying srv.Server.

func (*App) Dispatch

func (a *App) Dispatch(ctx context.Context, name string, payload ...any) (any, error)

Dispatch calls a named action handler.

func (*App) Listen

func (a *App) Listen(addr string) error

Listen starts the HTTP server and scheduler, then blocks until shutdown.

func (*App) Log

func (a *App) Log(logger *slog.Logger) *App

Log sets the application logger.

func (*App) Provide

func (a *App) Provide(name string, instance any) *App

Provide registers a named dependency for injection into handler structs.

func (*App) RegisterAction

func (a *App) RegisterAction(name string, handler func(ctx context.Context, payload ...any) (any, error)) *App

RegisterAction registers a named action handler for dispatch.

func (*App) RegisterHTTP

func (a *App) RegisterHTTP(h Handler) *App

RegisterHTTP registers a struct-tagged HTTP handler.

func (*App) Schedule

func (a *App) Schedule(name, cronExpr string, handler func(ctx context.Context) error) *App

Schedule registers a cron job.

func (*App) Use

func (a *App) Use(mw srv.Middleware) *App

Use adds middleware to the HTTP server.

type Handler

type Handler interface {
	Handle(ctx context.Context) (any, error)
}

Handler is the interface for declarative struct-tagged endpoints.

Jump to

Keyboard shortcuts

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