Documentation
¶
Overview ¶
Package app is the Visoto server: it loads the configuration, the SPARQL preprocessor and the templates, registers every route and runs the HTTP server. cmd/visoto is a thin wrapper around Main; the commercial edition calls Main with its own plugins.
Index ¶
- Constants
- func Main(plugins ...Plugin)
- func RenderName(c *gin.Context, templateName string) string
- type Access
- type Action
- type Authorizer
- type Denier
- type Host
- func (h *Host) DecodeConfig(v any) error
- func (h *Host) Handle(method, path string, action Action, handlers ...gin.HandlerFunc)
- func (h *Host) Logger() *slog.Logger
- func (h *Host) RegisterCollector(c prometheus.Collector)
- func (h *Host) SetAuthorizer(a Authorizer)
- func (h *Host) Stores() []Store
- func (h *Host) Use(mw ...gin.HandlerFunc)
- type Plugin
- type Store
Constants ¶
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Access ¶
Access is one authorization decision: an Action on a store, optionally for one resource IRI.
type Authorizer ¶
type Authorizer = access.Authorizer
Authorizer decides every guarded request. See access.Authorizer for the context contract: context.Background() means an anonymous caller.
type Denier ¶
Denier is optionally implemented by an Authorizer that answers a refused request itself — a redirect to sign-in for an anonymous caller, say. It must write the response; c is aborted afterwards either way.
type Host ¶
type Host struct {
// ConfigPath is the visoto.config the server loaded; a plugin reads its own
// section from it.
ConfigPath string
// DataDir is the directory for local state (SQLite files).
DataDir string
// contains filtered or unexported fields
}
Host is what a plugin gets to work with.
func TestHost ¶ added in v0.3.0
TestHost is a Host on a bare router, for testing a plugin against the real route guard and /_auth/check without the rest of the server. stores become the configured endpoints, the first one the default. It replaces the package's configuration and authorizer, so tests that use it must not run in parallel.
func (*Host) DecodeConfig ¶ added in v0.2.0
DecodeConfig decodes visoto.config into v, with the core's ${VAR} and .env expansion; a plugin declares only its own section, e.g. a struct with an `Accounts … toml:"accounts"` field.
func (*Host) Handle ¶
func (h *Host) Handle(method, path string, action Action, handlers ...gin.HandlerFunc)
Handle registers a plugin route with the access it needs, through the same table and guard as the core routes.
func (*Host) RegisterCollector ¶ added in v0.2.0
func (h *Host) RegisterCollector(c prometheus.Collector)
RegisterCollector adds a Prometheus collector to /metrics.
func (*Host) SetAuthorizer ¶
func (h *Host) SetAuthorizer(a Authorizer)
SetAuthorizer replaces the allow-all default. An Authorizer that also implements Denier answers refused requests itself.
func (*Host) Use ¶
func (h *Host) Use(mw ...gin.HandlerFunc)
Use adds middleware that runs on every route, before its guard — the place to put the caller's identity into the request context.