From 8530c76f2da7f07441973f559c7bc975da57d017 Mon Sep 17 00:00:00 2001 From: Jason Streifling Date: Sat, 9 Mar 2024 10:27:04 +0100 Subject: [PATCH] Missed main when converting to MVC --- cmd/main.go | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 0f19231..d150610 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -6,12 +6,13 @@ import ( "net/http" "os" - "streifling.com/jason/cpolis/cmd/data" - "streifling.com/jason/cpolis/cmd/ui" + "streifling.com/jason/cpolis/cmd/control" + "streifling.com/jason/cpolis/cmd/model" + "streifling.com/jason/cpolis/cmd/view" ) func init() { - gob.Register(data.User{}) + gob.Register(model.User{}) } func main() { @@ -23,45 +24,45 @@ func main() { defer logFile.Close() // log.SetOutput(logFile) - db, err := data.OpenDB("cpolis") + db, err := model.OpenDB("cpolis") if err != nil { log.Fatalln(err) } defer db.Close() - key, err := data.LoadKey("tmp/key.gob") + key, err := control.LoadKey("tmp/key.gob") if err != nil { - key, err = data.NewKey() + key, err = control.NewKey() if err != nil { log.Fatalln(err) } - data.SaveKey(key, "tmp/key.gob") + control.SaveKey(key, "tmp/key.gob") } - store := data.NewCookieStore(key) + store := control.NewCookieStore(key) mux := http.NewServeMux() mux.Handle("/web/static/", http.StripPrefix("/web/static/", http.FileServer(http.Dir("web/static/")))) - mux.HandleFunc("/", ui.HomePage(db, store)) + mux.HandleFunc("/", view.HomePage(db, store)) - mux.HandleFunc("GET /create-tag/", ui.CreateTag) - mux.HandleFunc("GET /create-user/", ui.CreateUser) - mux.HandleFunc("GET /hub/", ui.ShowHub(store)) - mux.HandleFunc("GET /rss/", ui.ShowRSS( + mux.HandleFunc("GET /create-tag/", view.CreateTag) + mux.HandleFunc("GET /create-user/", view.CreateUser) + mux.HandleFunc("GET /hub/", view.ShowHub(store)) + mux.HandleFunc("GET /rss/", view.ShowRSS( db, "Freimaurer Distrikt Niedersachsen und Sachsen-Anhalt", "https://distrikt-ni-st.de", "Freiheit, Gleichheit, Brüderlichkeit, Toleranz und Humanität", )) - mux.HandleFunc("GET /unpublished-articles/", ui.ShowUnpublishedArticles(db)) - mux.HandleFunc("GET /write-article/", ui.WriteArticle(db)) + mux.HandleFunc("GET /unpublished-articles/", view.ShowUnpublishedArticles(db)) + mux.HandleFunc("GET /write-article/", view.WriteArticle(db)) - mux.HandleFunc("POST /add-tag/", ui.AddTag(db, store)) - mux.HandleFunc("POST /add-user/", ui.AddUser(db, store)) - mux.HandleFunc("POST /finish-article/", ui.FinishArticle(db, store)) - mux.HandleFunc("POST /login/", ui.Login(db, store)) - mux.HandleFunc("POST /review-article/", ui.ReviewArticle(db, store)) - mux.HandleFunc("POST /publish-article/", ui.PublishArticle(db, store)) + mux.HandleFunc("POST /add-tag/", view.AddTag(db, store)) + mux.HandleFunc("POST /add-user/", view.AddUser(db, store)) + mux.HandleFunc("POST /finish-article/", view.FinishArticle(db, store)) + mux.HandleFunc("POST /login/", view.Login(db, store)) + mux.HandleFunc("POST /review-article/", view.ReviewArticle(db, store)) + mux.HandleFunc("POST /publish-article/", view.PublishArticle(db, store)) log.Fatalln(http.ListenAndServe(":8080", mux)) }