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() }
// NewTestApp creates a new app should be used in unit tests. func NewTestApp() *TestApp { router := mux.NewRouter() registry := ®istry.NopRegistry{} config := scroll.AppConfig{ Name: "test", Router: router, Registry: registry} return &TestApp{ RestHelper{}, scroll.NewAppWithConfig(config), httptest.NewServer(router), } }