示例#1
0
func main() {
	cfg, err := config.NewConfig()
	if err != nil {
		panic(err)
	}

	NewRouter(container.NewContainerBag(cfg)).Run()
}
示例#2
0
func GetNewTestConfig(c *gc.C, url string, filter string) *config.Config {
	cfg, err := config.NewConfig(&MockLoader{
		url:    url,
		filter: filter,
	})

	if err != nil {
		c.Error(err)
	}

	return cfg
}
示例#3
0
func main() {
	logging.SetFormatter(format)

	cfg, err := config.NewConfig(&config.FlagLoader{})
	if err != nil {
		panic(err)
	}

	var (
		cache    = cc.NewFileCache()
		buildbot = bb.NewBuildbotApi(cfg.BuildBotUrl, pool.NewRequestPool(), log)

		indexHandler    = handler.NewIndexHandler()
		buildersHandler = handler.NewBuildersHandler(cfg, buildbot, cache, log)
	)

	router := martini.Classic()
	router.Use(staticbin.Static("static/assets", Asset))
	router.Use(render.RendererBin(Asset, AssetNames(), render.Options{
		Directory:  "static/templates",
		Layout:     "layout",
		Extensions: []string{".tmpl", ".html"},
		Charset:    "UTF-8",
		IndentJSON: true,
		Funcs: []template.FuncMap{
			{
				"refreshSec": func() string {
					return strconv.Itoa(cfg.RefreshSec)
				},
				"buildbotUrl": func() string {
					return buildbot.GetUrl()
				},
				"hashedUrl": func() string {
					return cfg.HashedUrl
				},
			},
		},
	}))

	router.Get("/", indexHandler.ServeHTTP)
	router.Get("/builders", buildersHandler.GetBuilders)
	router.Get("/builder/:id", buildersHandler.GetBuilder)

	router.Run()
}