all repos — legit @ 2b57b6e0b1b936f45aa4ed8fd0ed2f57b7d370f3

web frontend for git

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 := Unveil("/usr/local/bin/git", "rx"); err != nil {
24		log.Fatalf("unveil: %s", err)
25	}
26
27	if err := UnveilPaths([]string{
28		"/dev/null",
29		c.Dirs.Static,
30		c.Repo.ScanPath,
31		c.Dirs.Templates,
32	},
33		"r"); err != nil {
34		log.Fatalf("unveil: %s", err)
35	}
36
37	mux := routes.Handlers(c)
38	addr := fmt.Sprintf("%s:%d", c.Server.Host, c.Server.Port)
39	log.Println("starting server on", addr)
40	log.Fatal(http.ListenAndServe(addr, mux))
41}