server

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Environment

type Environment struct {
	DisableDefaults bool
	// contains filtered or unexported fields
}

Environment is a full Jelly environment that contains all parameters needed to run a server. Creating an Environment prior to config loading allows all required external functionality to be properly registered.

func (*Environment) DumpConfig

func (env *Environment) DumpConfig(cfg jelly.Config) []byte

DumpConfig dumpes the given config to bytes. If Format is not set on the Config, YAML is assumed.

func (*Environment) LoadConfig

func (env *Environment) LoadConfig(file string) (jelly.Config, error)

LoadConfig loads a configuration from file. Ensure that UseComponent is first called on every component that will be configured (such as jelly/auth), and ensure RegisterConfigSection is called for each custom config section not associated with a component.

func (*Environment) NewServer

func (env *Environment) NewServer(cfg *jelly.Config) (jelly.RESTServer, error)

NewServer creates a new RESTServer ready to have new APIs added to it. All configured DBs are connected to before this function returns, and the config is retained for future operations. Any registered auto-APIs are automatically added via Add as per the configuration; this includes both built-in and user-supplied APIs.

func (*Environment) RegisterAuthenticator

func (env *Environment) RegisterAuthenticator(name string, authen jelly.Authenticator) error

RegisterAuthenticator registers an authenticator for use with other components in a jelly framework environment. This is generally not called directly but can be. If attempting to register the authenticator of a jelly.Component such as jelly/auth.Component, consider calling UseComponent instead as that will automatically call RegisterAuthenticator for any authenticators the component provides.

func (*Environment) RegisterConfigSection

func (env *Environment) RegisterConfigSection(name string, provider func() jelly.APIConfig) error

RegisterConfigSection registers a provider function, which creates an implementor of config.APIConfig, to the name of the config section that should be loaded into it. You must call this for every custom API config sections, or they will be given the default common config only at initialization.

func (*Environment) RegisterConnector

func (env *Environment) RegisterConnector(engine jelly.DBType, name string, connector func(jelly.DatabaseConfig) (jelly.Store, error)) error

RegisterConnector allows the specification of database connection methods. The registered name can then be specified as the connector field of any DB in config whose type is the given engine.

func (*Environment) SetMainAuthenticator

func (env *Environment) SetMainAuthenticator(name string) error

SetMainAuthenticator sets what the main authenticator in the middleware provider is. This provider will be used when obtaining middleware that uses an authenticator but no specific authenticator is specified. The name given must be the name of one previously registered with RegisterAuthenticator

func (*Environment) UseComponent

func (env *Environment) UseComponent(c jelly.Component)

UseComponent enables the given component and its section in config. Required to be called at least once for every pre-rolled component in use (such as jelly/auth) prior to loading config that contains its section. Calling UseComponent twice with a component with the same name will cause a panic.

Jump to

Keyboard shortcuts

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