nirvana: Index | Files | Directories

package nirvana

import ""


Package Files

banner.go nirvana.go


const  = "" /* 309 byte string literal not displayed */

Banner shows an ASCII art of nirvana.

const  = "" /* 2301 byte string literal not displayed */

Logo presents an ASCII art of nirvana logo.

func RegisterConfigInstaller Uses

func RegisterConfigInstaller(ci ConfigInstaller)

RegisterConfigInstaller registers a config installer.

type Config Uses

type Config struct {
    // contains filtered or unexported fields

Config describes configuration of server.

func NewConfig Uses

func NewConfig() *Config

NewConfig creates a pure config. If you don't know how to set filters and modifiers for specific scenario, please use NewDefaultConfig().

func NewDefaultConfig Uses

func NewDefaultConfig() *Config

NewDefaultConfig creates default config. Default config contains:

Filters: RedirectTrailingSlash, FillLeadingSlash, ParseRequestForm.
Modifiers: FirstContextParameter,
           ConsumeAllIfConsumesIsEmpty, ProduceAllIfProducesIsEmpty,
           ConsumeNoneForHTTPGet, ConsumeNoneForHTTPDelete,

func (*Config) Config Uses

func (c *Config) Config(name string) interface{}

Config gets external config by name. This method is for plugins.

func (*Config) Configure Uses

func (c *Config) Configure(configurers ...Configurer) *Config

Configure configs by configurers. It panics if an error occurs or config is locked.

func (*Config) IP Uses

func (c *Config) IP() string

IP returns listenning ip.

func (*Config) Locked Uses

func (c *Config) Locked() bool

Locked checks if the config is locked.

func (*Config) Logger Uses

func (c *Config) Logger() log.Logger

Logger returns logger.

func (*Config) Port Uses

func (c *Config) Port() uint16

Port returns listenning port.

func (*Config) Set Uses

func (c *Config) Set(name string, config interface{})

Set sets external config by name. This method is for plugins. Set a nil config will delete it.

type ConfigInstaller Uses

type ConfigInstaller interface {
    // Name is the external config name.
    Name() string
    // Install installs stuffs before server starting.
    Install(builder service.Builder, config *Config) error
    // Uninstall uninstalls stuffs after server terminating.
    Uninstall(builder service.Builder, config *Config) error

ConfigInstaller is used to install config to service builder.

func ConfigInstallerFor Uses

func ConfigInstallerFor(name string) ConfigInstaller

ConfigInstallerFor gets installer by name.

type Configurer Uses

type Configurer func(c *Config) error

Configurer is used to configure server config.

func Descriptor Uses

func Descriptor(descriptors ...definition.Descriptor) Configurer

Descriptor returns a configurer to add descriptors into config.

func Filter Uses

func Filter(filters ...service.Filter) Configurer

Filter returns a configurer to add filters into config.

func IP Uses

func IP(ip string) Configurer

IP returns a configurer to set ip into config.

func Logger Uses

func Logger(logger log.Logger) Configurer

Logger returns a configurer to set logger into config.

func Modifier Uses

func Modifier(modifiers ...service.DefinitionModifier) Configurer

Modifier returns a configurer to add definition modifiers into config.

func Port Uses

func Port(port uint16) Configurer

Port returns a configurer to set port into config.

func TLS Uses

func TLS(certFile, keyFile string) Configurer

TLS returns a configurer to set certFile and keyFile in config.

type Server Uses

type Server interface {
    // Serve starts to listen and serve requests.
    // The method won't return except an error occurs.
    Serve() error
    // Shutdown gracefully shuts down the server without interrupting any
    // active connections.
    Shutdown(ctx context.Context) error
    // Builder create a service builder for current server. Don't use this method directly except
    // there is a special server to hold http services. After server shutdown, clean resources via
    // returned cleaner.
    // This method always returns same builder until cleaner is called. Then it will
    // returns new one.
    Builder() (builder service.Builder, cleaner func() error, err error)

Server is a complete API server. The server contains a router to handle all requests form clients.

func NewServer Uses

func NewServer(c *Config) Server

NewServer creates a nirvana server. After creation, don't modify config. Also don't create another server with current config.



Package nirvana imports 9 packages (graph) and is imported by 10 packages. Updated 2019-07-03. Refresh now. Tools for package owners.