// 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), } }
func (s *ApiSuite) SetUpTest(c *C) { s.backend = membackend.NewMemBackend(registry.GetRegistry()) muxRouter := mux.NewRouter() hostRouter := hostroute.NewHostRouter() proxy, err := vulcan.NewProxy(hostRouter) configurator := configure.NewConfigurator(proxy) c.Assert(err, IsNil) InitProxyController(s.backend, adapter.NewAdapter(proxy), configurator.GetConnWatcher(), muxRouter) s.testServer = httptest.NewServer(muxRouter) s.client = NewClient(s.testServer.URL, registry.GetRegistry()) }
// 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), } }
// Create a new app with the provided configuration. func NewAppWithConfig(config AppConfig) *App { router := config.Router if router == nil { router = mux.NewRouter() } interval := config.Interval if interval == 0 { interval = defaultRegisterInterval } registration := ®istry.AppRegistration{Name: config.Name, Host: config.ListenIP, Port: config.ListenPort} heartbeater := registry.NewHeartbeater(registration, config.Registry, interval) return &App{ Config: config, router: router, heartbeater: heartbeater, stats: newAppStats(config.Client), } }
func (s *Service) initApi() error { s.apiRouter = mux.NewRouter() api.InitProxyController(s.backend, adapter.NewAdapter(s.proxy), s.configurator.GetConnWatcher(), s.apiRouter) return nil }