Ejemplo n.º 1
0
func main() {
	name := "leader"

	appConfig := scroll.AppConfig{
		Name:             name,
		ListenIP:         host,
		ListenPort:       port,
		Registry:         registry.NewLeaderRegistry("scrollexamples/leader", "master", 5),
		PublicAPIHost:    "public.local",
		ProtectedAPIHost: "private.local",
	}

	handlerSpec := scroll.Spec{
		Scopes:  []scroll.Scope{scroll.ScopePublic, scroll.ScopeProtected},
		Methods: []string{"GET"},
		Paths:   []string{"/"},
		Handler: index,
	}

	fmt.Printf("Starting %s on %s:%d...\n", name, host, port)

	app := scroll.NewAppWithConfig(appConfig)
	app.AddHandler(handlerSpec)
	app.Run()
}
Ejemplo n.º 2
0
// NewTestApp creates a new app should be used in unit tests.
func NewTestApp() *TestApp {
	router := mux.NewRouter()
	return &TestApp{
		RestHelper{},
		scroll.NewAppWithConfig(scroll.AppConfig{Router: router}),
		httptest.NewServer(router),
	}
}
Ejemplo n.º 3
0
// NewTestApp creates a new app should be used in unit tests.
func NewTestApp() *TestApp {
	router := mux.NewRouter()
	registry := &registry.NopRegistry{}
	config := scroll.AppConfig{
		Name:     "test",
		Router:   router,
		Registry: registry}

	return &TestApp{
		RestHelper{},
		scroll.NewAppWithConfig(config),
		httptest.NewServer(router),
	}
}