Files
summercms/pact/capabilities.go
Jakub Zych 4ee4c4a2fc feat(03-01): add ServeMux groups, JWT verifier, and serve command
Named middleware resolves at boot, HS256 tokens are pinned with required
exp/sub, and both binaries expose a signal-aware serve command.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-17 20:04:13 +02:00

75 lines
2.0 KiB
Go

package pact
import (
"io/fs"
"net/http"
"git.golem15.com/golem15/summercms/bonfire"
"github.com/go-gormigrate/gormigrate/v2"
)
// HasCommands is implemented by plugins that register console commands.
type HasCommands interface {
Commands() []bonfire.Command
}
// HasConfig is implemented by plugins that ship default YAML configuration.
// ConfigFS should contain files such as config/config.yaml, merged later at
// the plugin ID path.
type HasConfig interface {
ConfigFS() fs.FS
}
// HasMigrations is implemented by plugins that ship an ordered gormigrate
// set. The kernel runs each set in party.Activate order with a separate
// history table per plugin ID.
type HasMigrations interface {
Migrations() []*gormigrate.Migration
}
// Middleware is a named HTTP wrapper registered by a plugin.
type Middleware func(http.Handler) http.Handler
// HasMiddleware is implemented by plugins that register named middleware.
type HasMiddleware interface {
Middlewares() map[string]Middleware
}
// Router is the Laravel-like group builder implemented by surf.
type Router interface {
Group(prefix string, middleware []string, fn func(Router))
Get(path string, handler http.HandlerFunc, middleware ...string)
}
// HasRoutes is implemented by plugins that declare HTTP routes.
type HasRoutes interface {
Routes(Router) error
}
// HasModels is implemented by plugins that expose GORM models.
type HasModels interface {
Models() []any
}
// OptionalMessage is a service an optional plugin may publish so other
// plugins can integrate without importing that plugin's package.
type OptionalMessage interface {
Message() string
}
// Future capability families are type-asserted when their first consumer
// packages exist:
//
// HasJobs
// HasListeners
// HasAdminControllers
// HasNavigation
// HasPermissions
// HasSchedule
// HasMailTemplates
// HasLang
//
// The kernel type-asserts HasConfig (party, before Register), HasCommands
// (generated app main, after Boot), HasMigrations (lagoon migrate), and
// HasMiddleware/HasRoutes (surf assemble).