Documentation ¶
Index ¶
- Constants
- func RegisterConfigInstaller(ci ConfigInstaller)
- type Config
- type ConfigInstaller
- type Configurer
- func APIStyle(apiStyle service.APIStyle) Configurer
- func Descriptor(descriptors ...interface{}) Configurer
- func Filter(filters ...service.Filter) Configurer
- func IP(ip string) Configurer
- func Logger(logger log.Logger) Configurer
- func Modifier(modifiers ...service.DefinitionModifier) Configurer
- func Port(port uint16) Configurer
- func TLS(certFile, keyFile string) Configurer
- type Server
Constants ¶
const Banner = `` /* 307-byte string literal not displayed */
Banner shows an ASCII art of nirvana.
const Logo = `` /* 2299-byte string literal not displayed */
Logo presents an ASCII art of nirvana logo.
Variables ¶
This section is empty.
Functions ¶
func RegisterConfigInstaller ¶
func RegisterConfigInstaller(ci ConfigInstaller)
RegisterConfigInstaller registers a config installer.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config describes configuration of server.
func NewConfig ¶
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 ¶
func NewDefaultConfig() *Config
NewDefaultConfig creates default config. Default config contains:
Filters: RedirectTrailingSlash, FillLeadingSlash, ParseRequestForm. Modifiers: FirstContextParameter, ConsumeAllIfConsumesIsEmpty, ProduceAllIfProducesIsEmpty, ConsumeNoneForHTTPGet, ConsumeNoneForHTTPDelete, ProduceNoneForHTTPDelete.
func (*Config) Configure ¶
func (c *Config) Configure(configurers ...Configurer) *Config
Configure configs by configurers. It panics if an error occurs or config is locked.
type ConfigInstaller ¶
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 ¶
func ConfigInstallerFor(name string) ConfigInstaller
ConfigInstallerFor gets installer by name.
type Configurer ¶
Configurer is used to configure server config.
func APIStyle ¶ added in v0.3.0
func APIStyle(apiStyle service.APIStyle) Configurer
APIStyle returns a configurer to set api style into config.
func Descriptor ¶
func Descriptor(descriptors ...interface{}) Configurer
Descriptor returns a configurer to add descriptors into config.
func Filter ¶
func Filter(filters ...service.Filter) Configurer
Filter returns a configurer to add filters into config.
func Logger ¶
func Logger(logger log.Logger) Configurer
Logger returns a configurer to set logger into config.
func Modifier ¶
func Modifier(modifiers ...service.DefinitionModifier) Configurer
Modifier returns a configurer to add definition modifiers into config.
func TLS ¶ added in v0.2.0
func TLS(certFile, keyFile string) Configurer
TLS returns a configurer to set certFile and keyFile in config.
type Server ¶
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 from clients.