package main

import (
	"html/template"
	"log"
	"net/http"

	"streifling.com/jason/cpolis/cmd/handlers"
)

func main() {
	mux := http.NewServeMux()

	mux.Handle("/web/static/", http.StripPrefix("/web/static/", http.FileServer(http.Dir("web/static/"))))
	mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		template.Must(template.ParseFiles("web/templates/index.html", "web/templates/editor.html")).Execute(w, nil)
	})

	mux.HandleFunc("POST /finished-edit/", handlers.HandleFinishedEdit())

	log.Fatalln(http.ListenAndServe(":8080", mux))
}
