From 616df720413f03e0403538e834fc557cc73de443 Mon Sep 17 00:00:00 2001 From: Jason Streifling Date: Tue, 10 Oct 2023 19:19:17 +0200 Subject: [PATCH] =?UTF-8?q?package=20db=20zu=20data=20umbenannt,=20au?= =?UTF-8?q?=C3=9Ferdem=20db.Open()=20zu=20data.OpenDB()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 5 +++-- packages/{db => data}/db.go | 4 ++-- packages/server/server.go | 8 ++++---- 3 files changed, 9 insertions(+), 8 deletions(-) rename packages/{db => data}/db.go (98%) diff --git a/main.go b/main.go index f6979c1..cbbaf18 100644 --- a/main.go +++ b/main.go @@ -4,7 +4,7 @@ import ( "log" "net/http" - "streifling.com/jason/sicherheitsunterweisung/packages/db" + "streifling.com/jason/sicherheitsunterweisung/packages/data" "streifling.com/jason/sicherheitsunterweisung/packages/server" ) @@ -13,7 +13,7 @@ func main() { i, j = 1, 1 mux := http.NewServeMux() - db, err := db.Open("sicherheitsunterweisung") + db, err := data.OpenDB("sicherheitsunterweisung") if err != nil { log.Fatalln(err) } @@ -24,6 +24,7 @@ func main() { mux.HandleFunc("/new-briefing/", server.DisplayForm(&i)) mux.HandleFunc("/add-participant/", server.AddParticipant(&i)) mux.HandleFunc("/submit-form/", server.SubmitForm(db, &i, &j)) + mux.HandleFunc("/generate-uuid/", server.GenerateUUID()) log.Fatalln(http.ListenAndServe(":8080", mux)) } diff --git a/packages/db/db.go b/packages/data/db.go similarity index 98% rename from packages/db/db.go rename to packages/data/db.go index 802436b..9f56b53 100644 --- a/packages/db/db.go +++ b/packages/data/db.go @@ -1,4 +1,4 @@ -package db +package data import ( "bufio" @@ -43,7 +43,7 @@ func reverseOrder(bs *[]types.Briefing) { } } -func Open(dbName string) (*DB, error) { +func OpenDB(dbName string) (*DB, error) { var err error db := new(DB) diff --git a/packages/server/server.go b/packages/server/server.go index 10ab54a..512b654 100644 --- a/packages/server/server.go +++ b/packages/server/server.go @@ -8,11 +8,11 @@ import ( "log" "net/http" - "streifling.com/jason/sicherheitsunterweisung/packages/db" + "streifling.com/jason/sicherheitsunterweisung/packages/data" "streifling.com/jason/sicherheitsunterweisung/packages/types" ) -func DisplayTable(db *db.DB) http.HandlerFunc { +func DisplayTable(db *data.DB) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { bs, err := db.ReadAll() if err != nil { @@ -22,7 +22,7 @@ func DisplayTable(db *db.DB) http.HandlerFunc { } } -func DisplayResults(db *db.DB) http.HandlerFunc { +func DisplayResults(db *data.DB) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { bs, err := db.ReadByName(r.PostFormValue("search")) if err != nil { @@ -45,7 +45,7 @@ func AddParticipant(i *int64) http.HandlerFunc { } } -func SubmitForm(db *db.DB, i, j *int64) http.HandlerFunc { +func SubmitForm(db *data.DB, i, j *int64) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { b := new(types.Briefing)