camlistore.org: camlistore.org/pkg/serverinit Index | Files

package serverinit

import "camlistore.org/pkg/serverinit"

Package serverinit is responsible for mapping from a Camlistore configuration file and instantiating HTTP Handlers for all the necessary endpoints.

Index

Package Files

devmode.go env.go genconfig.go serverinit.go

Variables

var ErrCamliPath = errors.New("invalid Camlistore request path")

func WriteDefaultConfigFile Uses

func WriteDefaultConfigFile(filePath string, useSQLite bool) error

WriteDefaultConfigFile generates a new default high-level server configuration file at filePath. If useSQLite, the default indexer will use SQLite, otherwise leveldb. If filePath already exists, it is overwritten.

type Config Uses

type Config struct {
    jsonconfig.Obj
    UIPath string // Not valid until after InstallHandlers
    // contains filtered or unexported fields
}

A Config is the wrapper around a Camlistore 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.

func DefaultEnvConfig Uses

func DefaultEnvConfig() (*Config, error)

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 Uses

func Load(config []byte) (*Config, error)

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 Uses

func LoadFile(filename string) (*Config, error)

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 Uses

func (config *Config) AppURL() map[string]string

AppURL returns a map of app name to app base URL for all the configured server apps.

func (*Config) InstallHandlers Uses

func (config *Config) InstallHandlers(hi HandlerInstaller, baseURL string, reindex bool, context *http.Request) (shutdown io.Closer, err error)

InstallHandlers creates and registers all the HTTP Handlers needed by config into the provided HandlerInstaller.

baseURL is required and specifies the root of this webserver, without trailing slash. context may be nil (used and required by App Engine only)

The returned shutdown value can be used to cleanly shut down the handlers.

func (*Config) StartApps Uses

func (config *Config) StartApps() error

StartApps starts all the server applications that were configured during InstallHandlers. It should only be called after camlistored has started serving, since these apps might request some configuration from Camlistore to finish initializing.

func (*Config) UploadPublicKey Uses

func (config *Config) UploadPublicKey() error

UploadPublicKey uploads the public key blob with the sign handler that was configured during InstallHandlers.

type HandlerInstaller Uses

type HandlerInstaller interface {
    Handle(path string, h http.Handler)
}

A HandlerInstaller is anything that can register an HTTP Handler at a prefix path. Both *http.ServeMux and camlistore.org/pkg/webserver.Server implement HandlerInstaller.

Package serverinit imports 40 packages (graph) and is imported by 8 packages. Updated 2018-02-13. Refresh now. Tools for package owners.