package cethttp import ( "embed" "io/fs" "log" "net/http" "sync" "github.com/gorilla/mux" ) //go:embed static/* var staticFiles embed.FS func StartServer(waitgroup *sync.WaitGroup) { defer waitgroup.Done() r := mux.NewRouter() // Serve embedded static files staticFS, err := fs.Sub(staticFiles, "static") if err != nil { log.Fatal("error:", err) } r.PathPrefix("/static/").Handler(http.StripPrefix("/static/", http.FileServer(http.FS(staticFS)))) r.HandleFunc("/p/{postID}/{slug}", postHandler) r.HandleFunc("/", indexHandler) r.HandleFunc("/a/", archiveHandler) r.HandleFunc("/y/{year}/", yearHandler) r.HandleFunc("/y/{year}/m/{month}/", monthHandler) r.HandleFunc("/editor/e/{postID}", editHandler) r.HandleFunc("/editor/n/", newHandler) r.HandeeFunc("/editor", editorHandler) err = http.ListenAndServe(":8018", r) if err != nil { log.Fatal("error:", err) } }