Esempio n. 1
0
// Start doing the HTTP server/router thing
func Start() {
	curDir, err := util.GetExecDirectory()
	if err != nil {
		log.Fatal(err)
	}
	indexFile := path.Join(curDir, "/index.html")
	webAppDir = config.Frontend.WebAppDir
	finishIndex(indexFile)
	r := mux.NewRouter()
	// Serve the login page
	r.HandleFunc("/login", getLogin).Methods("GET")
	// Serve the new user registration page
	r.HandleFunc("/register", getRegistration).Methods("GET")
	// Serve the forgot password page
	r.HandleFunc("/forgot_password", getForgotPassword).Methods("GET")
	// Serve the rest password page
	r.HandleFunc("/reset_password", getResetPassword).Methods("GET")
	// Serve the Main app
	r.StrictSlash(true).HandleFunc("/app", getAppRoot)
	// Fetch the location of the homepage
	r.HandleFunc("/app/home", getHome).Methods("GET")
	// Serve up static assets
	r.PathPrefix("/app/resource/").
		Methods("GET").
		Handler(httpgzip.NewHandler(http.StripPrefix("/app/resource/",
			http.FileServer(http.Dir(webAppDir)))))
	//Handle other routes
	r.PathPrefix("/app/wikis").HandlerFunc(getAppRoot)
	r.PathPrefix("/app/users").HandlerFunc(getAppRoot)
	// Custom extensions (plugins) should use /app/x routes on the front end
	r.PathPrefix("/app/x").HandlerFunc(getAppRoot)
	// Handle API requests
	ar := r.PathPrefix("/api/" + config.ApiVersion).Subrouter()
	handleApiRoutes(ar)
	// Handle Plugin requests for frontend resources
	pr := r.PathPrefix("/app/plugin").Subrouter()
	handlePluginRoutes(pr)
	// Backend Plugin requests
	bpr := r.PathPrefix("/plugin").Subrouter()
	handlePluginBackendRoutes(bpr)
	log.Print("Starting HTTP router")
	if config.Service.UseSSL {
		certFile := config.Service.SSLCertFile
		keyFile := config.Service.SSLKeyFile
		log.Fatal(http.ListenAndServeTLS(":"+config.Service.Port,
			certFile, keyFile, r))
	} else {
		log.Fatal(http.ListenAndServe(":"+config.Service.Port, r))
	}
}
Esempio n. 2
0
// Initialize Default values
func LoadDefaults() {
	execDir, err := util.GetExecDirectory()
	if err != nil {
		log.Fatal(err)
	}
	Service.DomainName = "127.0.0.1"
	Service.RegistryLocation = "http://127.0.0.1:2379"
	Service.Port = "6000"
	Service.ApiVersion = "v1"
	Service.NodeId = "cs1"
	Service.UseSSL = false
	Frontend.WebAppDir = path.Join(execDir, "web_app/app")
	Frontend.PluginDir = path.Join(execDir, "plugins")
	Frontend.Homepage = ""
	Database.DbAddr = "127.0.0.1"
	Database.DbPort = "5984"
	Database.UseSSL = false
	Database.DbAdminUser = "******"
	Database.DbAdminPassword = "******"
	Database.DbTimeout = "500"
	Database.MainDb = "main_ut"
	Logger.LogFile = "out.log"
	Logger.MaxSize = 10
	Logger.MaxBackups = 3
	Logger.MaxAge = 30
	Auth.Authenticator = auth.Standard
	Auth.SessionTimeout = 600
	Auth.PersistentSessions = true
	Auth.AllowGuest = true
	Auth.MinPasswordLength = 6
	Users.AvatarDb = "avatar_ut"
	Notifications.TemplateDir = "templates"
	Notifications.UseHtmlTemplates = true
	Notifications.MainSiteUrl = "http://*****:*****@localhost"
}
Esempio n. 3
0
// Load Frontend configuration options
func SetFrontendConfig(frontendSection *configparser.Section) {
	execDir, _ := util.GetExecDirectory()
	for key, value := range frontendSection.Options() {
		switch key {
		case "webAppDir":
			if value[0] != '/' {
				Frontend.WebAppDir = path.Join(execDir, value)
			} else {
				Frontend.WebAppDir = value
			}
		case "pluginDir":
			if value[0] != '/' {
				Frontend.PluginDir = path.Join(execDir, value)
			} else {
				Frontend.PluginDir = value
			}
		case "homepage":
			Frontend.Homepage = value
		}
	}
}
Esempio n. 4
0
// Initialize Default values
func LoadDefaults() {
	execDir, err := util.GetExecDirectory()
	if err != nil {
		log.Fatal(err)
	}
	ServiceRegistry.CacheRefreshInterval = 75
	ServiceRegistry.EntryTTL = 60
	Frontend.WebAppDir = path.Join(execDir, "web_app/app")
	Frontend.PluginDir = path.Join(execDir, "plugins")
	Frontend.Homepage = ""
	Database.DbAddr = "127.0.0.1"
	Database.DbPort = "5984"
	Database.UseSSL = false
	Database.DbAdminUser = "******"
	Database.DbAdminPassword = "******"
	Database.DbTimeout = "0"
	Database.MainDb = "main_ut"
	Logger.LogFile = "wikifeat-service.log"
	Logger.MaxSize = 10
	Logger.MaxBackups = 3
	Logger.MaxAge = 30
	Auth.Authenticator = "standard"
	Auth.SessionTimeout = 600
	Auth.PersistentSessions = true
	Auth.AllowGuest = true
	Auth.AllowNewUserRegistration = false
	Auth.MinPasswordLength = 6
	Users.AvatarDb = "avatar_ut"
	Notifications.TemplateDir = "templates"
	Notifications.UseHtmlTemplates = true
	Notifications.MainSiteUrl = "http://*****:*****@localhost"
}