serverinit

package
v0.0.0-...-c8ec3b5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 14, 2016 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

View Source
var ErrCamliPath = errors.New("Invalid Camlistore request path")

Functions

func WriteDefaultConfigFile

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.

Types

type Config

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

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

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

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

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

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

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.

type HandlerInstaller

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL