all repos — legit @ 45d1c6c2ecf2f53f468d1eeef46aecb749e7086d

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	err = UnveilPaths([]string{c.Dirs.Static, c.Repo.ScanPath, c.Dirs.Templates}, "r")
24	if err != nil {
25		log.Fatalf("unveil: %w", err)
26	}
27
28	mux := routes.Handlers(c)
29	addr := fmt.Sprintf("%s:%d", c.Server.Host, c.Server.Port)
30	log.Println("starting server on", addr)
31	log.Fatal(http.ListenAndServe(addr, mux))
32}