summaryrefslogblamecommitdiffstats
path: root/main.go
blob: 942b9de3b1dc63e90f4b77774db3cb3e17bffdd0 (plain) (tree)
1
2
3
4
5
6
7
8
9
10



              
             


                  

                                     











                                                                              



                                                                                         
                                 


                                                                  
 
package main

import (
	"flag"
	"fmt"
	"log"
	"net/http"

	"git.icyphox.sh/legit/config"
	"git.icyphox.sh/legit/routes"
)

func main() {
	var cfg string
	flag.StringVar(&cfg, "config", "./config.yaml", "path to config file")
	flag.Parse()

	c, err := config.Read(cfg)
	if err != nil {
		log.Fatal(err)
	}

	// for path := range []string{c.Dirs.Static, c.Repo.ScanPath, c.Dirs.Templates} {
	// 	Unveil(path, "r")
	// }

	mux := routes.Handlers(c)
	addr := fmt.Sprintf("%s:%d", c.Server.Host, c.Server.Port)
	log.Println("starting server on", addr)
	log.Fatal(http.ListenAndServe(addr, mux))
}