Documentation ¶
Overview ¶
Package serverinit is responsible for mapping from a Perkeep configuration file and instantiating HTTP Handlers for all the necessary endpoints.
Index ¶
- Variables
- func WriteDefaultConfigFile(filePath string) error
- type Config
- func (c *Config) AppURL() map[string]string
- func (c *Config) BaseURL() string
- func (c *Config) HTTPS() bool
- func (c *Config) HTTPSCert() string
- func (c *Config) HTTPSKey() string
- func (c *Config) InstallHandlers(hi HandlerInstaller, baseURL string) (shutdown io.Closer, err error)
- func (c *Config) IsTailscaleListener() bool
- func (c *Config) KeyRingAndId() (keyRing, keyId string, err error)
- func (c *Config) ListenAddr() string
- func (c *Config) LowLevelJSONConfig() map[string]interface{}deprecated
- func (c *Config) SetKeepGoing(v bool)
- func (c *Config) SetReindex(v bool)
- func (c *Config) StartApps() error
- func (c *Config) UIPath() string
- func (c *Config) UploadPublicKey(ctx context.Context) error
- type HandlerInstaller
Constants ¶
This section is empty.
Variables ¶
var ErrCamliPath = errors.New("invalid Perkeep request path")
Functions ¶
func WriteDefaultConfigFile ¶
WriteDefaultConfigFile generates a new default high-level server configuration file at filePath. The default indexer will use SQLite. If filePath already exists, it is overwritten.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
A Config is the wrapper around a Perkeep JSON configuration file. Files on disk can be in either high-level or low-level format, but the Load function always returns the Config in its low-level format (a.k.a. the "handler" format).
TODO(bradfitz): document and/or link to the low-level format; for now you can see the high-level config format at https://perkeep.org/pkg/types/serverconfig/#Config and the the low-level format by running "camtool dumpconfig".
func DefaultEnvConfig ¶
DefaultEnvConfig returns the default configuration when running on a known environment. Currently this just includes Google Compute Engine. If the environment isn't known (nil, nil) is returned.
func Load ¶
Load returns a low-level "handler config" from the provided config. If the config doesn't contain a top-level JSON key of "handlerConfig" with boolean value true, the configuration is assumed to be a high-level "user config" file, and transformed into a low-level config.
func LoadFile ¶
LoadFile returns a low-level "handler config" from the provided filename. If the config file doesn't contain a top-level JSON key of "handlerConfig" with boolean value true, the configuration is assumed to be a high-level "user config" file, and transformed into a low-level config.
func (*Config) AppURL ¶
AppURL returns a map of app name to app base URL for all the configured server apps.
func (*Config) BaseURL ¶
BaseURL returns the optional URL prefix listening the root of this server. It does not end in a trailing slash.
func (*Config) HTTPSCert ¶
HTTPSCert returns the optional path to an HTTPS public key certificate file.
func (*Config) InstallHandlers ¶
func (c *Config) InstallHandlers(hi HandlerInstaller, baseURL string) (shutdown io.Closer, err error)
InstallHandlers creates and registers all the HTTP Handlers needed by config into the provided HandlerInstaller and validates that the configuration is valid.
baseURL is required and specifies the root of this webserver, without trailing slash.
The returned shutdown value can be used to cleanly shut down the handlers.
func (*Config) IsTailscaleListener ¶
IsTailscaleListener reports whether c is configured to run in Tailscale tsnet mode.
func (*Config) KeyRingAndId ¶
KeyRingAndId returns the GPG identity keyring path and the user's GPG keyID (TODO: length/case), if configured. TODO: which error value if not configured?
func (*Config) ListenAddr ¶
ListenAddr returns the optional configured listen address in ":port" or "ip:port" form.
func (*Config) LowLevelJSONConfig
deprecated
func (*Config) SetKeepGoing ¶
SetKeepGoing changes each configured prefix to set "keepGoing" to true. This indicates that validation, reindexing, or recovery behavior should not cause the process to end.
func (*Config) SetReindex ¶
func (*Config) StartApps ¶
StartApps starts all the server applications that were configured during InstallHandlers. It should only be called after perkeepd has started serving, since these apps might request some configuration from Perkeep to finish initializing.
type HandlerInstaller ¶
A HandlerInstaller is anything that can register an HTTP Handler at a prefix path. Both *http.ServeMux and perkeep.org/pkg/webserver.Server implement HandlerInstaller.