Beispiel #1
0
func main() {
	// Set up dependencies
	c := &router.Context{
		Config: parseFlags(),
	}

	if err := setupDependencies(c); err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}

	httputil.DefaultEncoder.MaxReadLen = c.Config.MaxTemplateLength

	// Set up routes
	handler := router.NewHandler(c)
	registerDeploymentRoutes(c, handler)
	registerChartRepoRoutes(c, handler)

	// Now create a server.
	log.Printf("Starting Manager %s on %s", version.Version, c.Config.Address)
	if err := http.ListenAndServe(c.Config.Address, handler); err != nil {
		log.Printf("Server exited with error %s", err)
		os.Exit(1)
	}
}
Beispiel #2
0
// httpHarness is a simple test server fixture.
// Simple fixture for standing up a test server with a single route.
//
// You must Close() the returned server.
func httpHarness(c *router.Context, route string, fn router.HandlerFunc) *httptest.Server {
	h := router.NewHandler(c)
	h.Add(route, fn)
	return httptest.NewServer(h)
}