all repos — legit @ b2b18250412af9ce04a45a015e7952dc84b8016c

web frontend for git, written in go

main.go (view raw)

 1package main
 2
 3import (
 4	"flag"
 5	"fmt"
 6	"log"
 7	"net/http"
 8
 9	"git.icyphox.sh/legit/config"
10	"git.icyphox.sh/legit/routes"
11)
12
13func main() {
14	var cfg string
15	flag.StringVar(&cfg, "config", "./config.yaml", "path to config file")
16	flag.Parse()
17
18	c, err := config.Read(cfg)
19	if err != nil {
20		log.Fatal(err)
21	}
22
23	if err := UnveilPaths([]string{
24		c.Dirs.Static,
25		c.Repo.ScanPath,
26		c.Dirs.Templates,
27	},
28		"r"); err != nil {
29		log.Fatalf("unveil: %s", err)
30	}
31
32	mux := routes.Handlers(c)
33	addr := fmt.Sprintf("%s:%d", c.Server.Host, c.Server.Port)
34	log.Println("starting server on", addr)
35	log.Fatal(http.ListenAndServe(addr, mux))
36}