From 09d882dc10688e395d1bbca3867fa955f5409f41 Mon Sep 17 00:00:00 2001 From: Lomanic Date: Sun, 4 Oct 2020 21:40:13 +0200 Subject: [PATCH] WIP --- main.go | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index 676d5a7..87b80a1 100644 --- a/main.go +++ b/main.go @@ -1,16 +1,45 @@ package main import ( - "fmt" - "log" - "net/http" + "fmt" + "log" + "net/http" + "os" + "path/filepath" + "time" + "io/ioutil" ) +const ( + db = "./.data/data.json" + defaultClosingTimeout = 5 * time.Minute + // epochTime = time.Date(1970, time.January, 01, 0, 0, 0, 0, time.UTC) +) + +var ( + fuzIsOpen = false + epochTime = time.Date(1970, time.January, 01, 0, 0, 0, 0, time.UTC) + lastSeen = epochTime + lastOpened = epochTime + lastClosed = epochTime +) + +func init() { + err := os.MkdirAll(filepath.Dir(db), 0755) + if err != nil { + panic(err) + } + content, err := ioutil.ReadFile(db) + if err != nil { + panic(err) + } +} + func handler(w http.ResponseWriter, r *http.Request) { - fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:]) + fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:]) } func main() { - http.HandleFunc("/", handler) - log.Fatal(http.ListenAndServe(":8080", nil)) + http.HandleFunc("/", handler) + log.Fatal(http.ListenAndServe(":8080", nil)) }