package main import ( "html/template" "log" "net" "net/http" "os" "github.com/julienschmidt/httprouter" ) const sockPath = "/srv/kumori.moe/sock/meikan.sock" var templates = template.Must(template.ParseGlob("templates/*.html")) func main() { os.Remove(sockPath) sock, err := net.Listen("unix", sockPath) if err != nil { log.Fatalln(err) return } router := httprouter.New() router.GET("/", index) router.ServeFiles("/static/*filepath", http.Dir("static/")) if err := os.Chmod(sockPath, 0770); err != nil { log.Fatalln(err) return } log.Fatal(http.Serve(sock, router)) } func index(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { err := templates.ExecuteTemplate(w, "home.html", nil) if err != nil { println(err) } }