You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gserver/server.go

41 lines
754 B
Go

8 years ago
package main
import (
"flag"
"fmt"
"log"
"net/http"
)
func initListeners(c *conf) {
for _, l := range c.Listen {
go func(l listen) {
addr := fmt.Sprintf("%s:%d", l.Host, l.Port)
if l.Cert != "" && l.Key != "" {
if err := http.ListenAndServeTLS(addr, l.Cert, l.Key,
&handler{enableProxy: l.EnableProxy}); err != nil {
log.Fatal(err)
}
} else {
if err := http.ListenAndServe(addr,
&handler{enableProxy: l.EnableProxy}); err != nil {
log.Fatal(err)
}
}
}(l)
}
8 years ago
}
func main() {
var configfile string
flag.StringVar(&configfile, "-c", "config.yaml", "config file")
8 years ago
flag.Parse()
c, err := loadConfig(configfile)
8 years ago
if err != nil {
log.Fatal(err)
}
initRouters(c)
initListeners(c)
select {}
8 years ago
}