aboutsummaryrefslogblamecommitdiff
path: root/main.go
blob: b4f0785908fdfa976160357f78ef91b5371d8575 (plain) (tree)
1
2
3
4
5
6
7
8
9






                  

                                           











                                                                              


                                       

                                 

                                             
         
 
                                 
                                                          
 
package main

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

	"git.sr.ht/~runxiyu/legitrx/config"
	"git.sr.ht/~runxiyu/legitrx/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)
	}

	if err := UnveilPaths([]string{
		c.Dirs.Static,
		c.Repo.ScanPath,
		c.Dirs.Templates,
	},
		"r"); err != nil {
		log.Fatalf("unveil: %s", err)
	}

	mux := routes.Handlers(c)
	log.Fatal(http.ListenAndServe(c.Server.Addr, mux))
}