package main import ( "fmt" "github.com/deranjer/gvc/server/engine" serverconfig "github.com/deranjer/gvc/server/serverconfig" "github.com/deranjer/store" "github.com/labstack/echo" "github.com/labstack/gommon/log" ) var version = "0.1" func main() { // Initialize a new server struct and config struct var err error var configPath string var conf serverconfig.GvcServerConfig configPath, err = serverconfig.FindConfig() if err != nil { fmt.Printf("Unable to find config file: %s\n", err) fmt.Println("Since no config found, creating a default config to use...") conf = serverconfig.GvcServerConfig{ Version: "0.1", Port: 80, RepoRootPath: "repos", //default repos directory will be cwd\repos } configPath = serverconfig.DefaultConfigPath // set the root path for our config so we can save that back to TOML err = store.Save(serverconfig.DefaultConfigPath, &conf) // Save our new default config back to TOML so it can be read in if err != nil { log.Fatalf("unable to save config to toml file: %s", err) } } err = store.Load(configPath, &conf) // existing conf was found or default conf created, so reading it in if err != nil { log.Fatalf("Error loading server config file into struct, please fix config, panic! \n%s", err) } err = serverconfig.ValidateConfig(&conf, configPath, version) // now that our config has been loaded, lets make sure it is valid if err != nil { log.Fatalf("unable to validate config, exiting: %s", err) } // Setup a new server instance var server engine.GVCServer server.Config = conf log.Info("Logger starting...") // Setup the web server e := echo.New() server.Echo = e //Start the routes //e.GET("/hello", server.Hello) e.GET("/info/:repoName", server.GetInfo) e.Logger.Fatal(e.Start(fmt.Sprintf("%s:%d", server.Config.BindIP, server.Config.Port))) }