Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrHandlerType = Handler must be «http.Handler» or «func(http.ResponseWriter, *http.Request)» ErrHandlerType = errors.New("Handler must be «http.Handler» or «func(http.ResponseWriter, *http.Request)»") // ErrConfigListenType = Configuration value «server.http(s).listen» must be a string type ErrConfigListenType = errors.New("Configuration value «server.http(s).listen» must be a string type") // ErrNoServers = No servers to run. Set «server.http(s).listen» in configuration file ErrNoServers = errors.New("No servers to run. Set «server.http(s).listen» in configuration file") // ErrDefaultLogEmpty = Configuration value «logger.defaultName» must be a non-empty string ErrDefaultLogEmpty = errors.New("Configuration value «logger.defaultName» must be a non-empty string") // ErrNeedTLSConfigForHTTPS = To create a https lisener, you need to specify the tls config options ErrNeedTLSConfigForHTTPS = errors.New("To create a https lisener, you need to specify the tls config options") )
Functions ¶
func DefaultConfig ¶
func DefaultConfig() map[string]interface{}
DefaultConfig returns default configuration options:
server.http.listen: ":http" server.timeout.read: "30s" server.timeout.write: "30s" server.timeout.idle: "30s" logger.defaultName: "wenex" logger.namePrefix: "log/" logger.usePrefix: "[!] " logger.useFlag: log.LstdFlags
Types ¶
type Chain ¶
type Chain struct {
// contains filtered or unexported fields
}
Chain struct
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router struct
func (*Router) StrictRoute ¶
StrictRoute routing binds expression to the end of line
type Run ¶
type Run struct {
// contains filtered or unexported fields
}
Run struct
type Wenex ¶
type Wenex struct { Router *Router Logger func(string) *log.Logger Config *joneva.Joneva // contains filtered or unexported fields }
Wenex struct
func New ¶
func New(configFile string, defaultConfig map[string]interface{}, logWriter LogWriter, configOverride ...string) (*Wenex, error)
New return a new Wenex object:
configFile: sets default config filename defaultConfig: contains default configuration parameters logWriter: interface for piping all logs to writer configOverride: overrides config values by values from specified files
defaultConfig doesn't replace parameters declared in configuration file and writes new values to configuration file.
func (*Wenex) Close ¶ added in v1.1.0
Close immediately closes all active net.Listeners and any connections in state StateNew, StateActive, or StateIdle. For a graceful shutdown, use Shutdown.
Close does not attempt to close (and does not even know about) any hijacked connections, such as WebSockets.
Close returns any error returned from closing the Server's underlying Listener(s).
func (*Wenex) ConnState ¶
ConnState specifies an optional callback function that is called when a client connection changes state. See the ConnState type and associated constants for details.
func (*Wenex) Run ¶
Run starts the web server. If an error occurs during the operation, the error will be returned. This method goes to asleep.
func (*Wenex) Shutdown ¶ added in v1.1.0
Shutdown gracefully shuts down the server without interrupting any active connections. Shutdown works by first closing all open listeners, then closing all idle connections, and then waiting indefinitely for connections to return to idle and then shut down. If the provided context expires before the shutdown is complete, Shutdown returns the context's error, otherwise it returns any error returned from closing the Server's underlying Listener(s).
When Shutdown is called, Serve, ListenAndServe, and ListenAndServeTLS immediately return ErrServerClosed. Make sure the program doesn't exit and waits instead for Shutdown to return.
Shutdown does not attempt to close nor wait for hijacked connections such as WebSockets. The caller of Shutdown should separately notify such long-lived connections of shutdown and wait for them to close, if desired. See RegisterOnShutdown for a way to register shutdown notification functions.
Once Shutdown has been called on a server, it may not be reused; future calls to methods such as Serve will return ErrServerClosed.