示例#1
0
文件: http.go 项目: napsy/lab
func init() {
	lab.LoadConf()
	if !(*useHttp || *useHttps) {
		return
	}
	conf := htmod.Config{
		Https: *useHttps,
		Addr:  *htaddr,
	}
	if conf.Https {
		conf.KeyFile = *keyFile
		conf.CertFile = *certFile
		conf.CAFile = *cacertFile
		log.Printf("starting https://%s/\n", conf.Addr)
	} else {
		log.Printf("starting http://%s/\n", conf.Addr)
	}
	lab.Register("htmod", htmod.New(conf))
}
示例#2
0
文件: main.go 项目: napsy/lab
func main() {
	lab.LoadConf()
	roots := build.Default.SrcDirs()
	lab.Register("roots", roots)
	lab.Register("gosrc", gosrc.New())
	golab := &golab{roots: roots}
	golab.ws = ws.New(ws.Config{
		CapHint: 8000,
		Watcher: ws.NewInotify,
		Filter:  golab,
		Handler: golab,
	})
	defer golab.ws.Close()
	lab.Register("ws", golab.ws)
	lab.Register("golab", golab)
	lab.Start()
	c := make(chan os.Signal)
	signal.Notify(c, os.Interrupt, os.Kill)
	<-c
}