Documentation
¶
Overview ¶
Example ¶
package main import ( "fmt" "log" "net/http" "git.ooo.ua/pub/uwe/v2" ) func main() { // fill configurations for the predefined worker that start an HTTP server apiCfg := Config{ Host: "0.0.0.0", Port: 8080, EnableCORS: false, ApiRequestTimeout: 0, } // initialize new instance of Chief chief := uwe.NewChief() chief.UseDefaultRecover() chief.SetEventHandler(uwe.STDLogEventHandler()) // will add workers into the pool chief.AddWorker("app-server", NewServer(apiCfg, getRouter())) // init all registered workers and run it all chief.Run() } // getRouter is used to declare an API scheme, func getRouter() http.Handler { // instead default can be used any another compatible router mux := http.NewServeMux() mux.HandleFunc("/hello/uwe", func(w http.ResponseWriter, r *http.Request) { _, _ = fmt.Fprintln(w, "hello world") }) log.Println("REST API router initialized") return mux }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Host string `json:"host" yaml:"host"` Port int `json:"port" yaml:"port"` EnableCORS bool `json:"enable_cors" yaml:"enable_cors"` ApiRequestTimeout int `json:"api_request_timeout" yaml:"api_request_timeout"` // nolint:golint }
Config is a parameters for `http.Server`.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is worker by default for starting a standard HTTP server. Server requires configuration and filled `http.Handler`. The HTTP server will work properly and will be correctly disconnected upon a signal from Supervisor (Chief). Warning: this Server does not process SSL/TLS certificates on its own.
To start an HTTPS server, look for a specific worker.
func NewServer ¶
NewServer returns a new instance of `Server` with the passed configuration and HTTP router.
func (*Server) Init ¶
Init is a method to satisfy `uwe.Worker` interface.
Click to show internal directories.
Click to hide internal directories.