Documentation
¶
Index ¶
- type App
- func (a *App) AddApi(provider func())
- func (a *App) AddDb(provider func() embed.FS)
- func (a *App) AddIdentityProvider(p api.IdentityProvider)
- func (a *App) AddService(fn func(context.Context))
- func (a *App) AddSubcommand(provider cli.SubcommandProvider)
- func (a *App) OnLogin(fn func(ctx context.Context, id api.Identity) (subject string, err error))
- func (a *App) Run() error
- func (a *App) SetFrontend(fsys fs.FS)
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 is a configured schemaf application. Use New to create one.
func New ¶
New creates a new App using the project name registered via constants.SetProjectName. The project name determines the database name, host, and migration prefix.
func (*App) AddApi ¶
func (a *App) AddApi(provider func())
AddApi registers all API endpoints by calling the generated provider function. Wire up in go/main.go: app.AddApi(api.Provider)
func (*App) AddDb ¶
AddDb registers the project's database migrations. Wire up in go/main.go: app.AddDb(db.Provider)
func (*App) AddIdentityProvider ¶ added in v1.10.0
func (a *App) AddIdentityProvider(p api.IdentityProvider)
AddIdentityProvider registers a custom identity provider. Its login route is POST /api/auth/{Name()}/login. A reserved name (a built-in such as "auth0") or a duplicate name makes the server fail at startup. Wire up in go/main.go: app.AddIdentityProvider(auth.PasskeyProvider{})
func (*App) AddService ¶ added in v0.6.0
AddService registers a background function that runs as a goroutine when the server starts (after DB init and migrations). The context is cancelled on server shutdown. Services are not started for CLI subcommands. Wire up in go/main.go: app.AddService(myworker.Run)
func (*App) AddSubcommand ¶ added in v0.2.0
func (a *App) AddSubcommand(provider cli.SubcommandProvider)
AddSubcommand registers a subcommand provider. Providers follow the same pattern as framework CLI subcommands (see cli/cmd/* for examples). Wire up in go/main.go: app.AddSubcommand(importer.SubcommandProvider)
func (*App) OnLogin ¶ added in v1.10.0
OnLogin sets the optional hook that maps a proven identity to the app's subject at login. Without it, the provider's subject is used unchanged. Returning api.ErrForbidden refuses the login (403). Claims such as email are only available here.
func (*App) Run ¶
Run hands over to Cobra for command routing. The "server" command (default when no subcommand is given) starts the HTTP server. Custom subcommands registered via AddSubcommand are mounted alongside it.
func (*App) SetFrontend ¶ added in v0.7.0
SetFrontend registers an embedded frontend filesystem for production serving. In dev mode, the server proxies to the frontend dev server instead. Wire up in go/main.go: app.SetFrontend(FrontendFS())