all repos — legit @ 2fe14eca63e9d3e907c7b725407c146a82cc129f

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		c.Dirs.Static,
29		c.Repo.ScanPath,
30		c.Dirs.Templates,
31	},
32		"r"); err != nil {
33		log.Fatalf("unveil: %s", err)
34	}
35
36	mux := routes.Handlers(c)
37	addr := fmt.Sprintf("%s:%d", c.Server.Host, c.Server.Port)
38	log.Println("starting server on", addr)
39	log.Fatal(http.ListenAndServe(addr, mux))
40}