package main import ( "errors" "fmt" "os" "repobrowser/internal/config" "repobrowser/internal/handlers" "github.com/gin-gonic/gin" ) func main() { configPath := os.Getenv("HOME") + "/.config/repobrowser.json" if _, err := os.Stat(configPath); errors.Is(err, os.ErrNotExist) { fmt.Printf("Config file %s doesn't exist\n", configPath) os.Exit(1) } cfg := config.GetClientConfig(configPath) //var c = RepositoryBrowserApp{Config: cfg} r := gin.Default() r.GET("/", handlers.HandleRepoList(cfg)) repo := r.Group("/:repo") { repo.GET("/", handlers.HandleIndex(cfg)) repo.GET("/refs", handlers.HandleRefs(cfg)) repo.GET("/log", handlers.HandleLog(cfg)) repo.GET("/commit", handlers.HandleCommit(cfg)) repo.GET("/history", handlers.HandleHistory(cfg)) repo.GET("/view", handlers.HandleView(cfg)) repo.GET("/raw", handlers.HandleRaw(cfg)) } if "" == cfg.Interface { fmt.Println("altgit running -> http://0.0.0.0:8080 \n") r.Run("0.0.0.0:8080") } else { fmt.Printf("altgit running -> http://%s\n", cfg.Interface) r.Run(cfg.Interface) } }