about summary refs log tree commit diff stats
path: root/cache.go
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2020-05-07 19:33:56 -0400
committerBen Morrison <ben@gbmor.dev>2020-05-07 19:33:56 -0400
commitfa8162c2100ef2198b38879cc888c178e4e29185 (patch)
tree92e5c04c293a9d2e3b17bd3c8531afa58802f246 /cache.go
parent281444e000918aa20d486ad71f62ff22afd42860 (diff)
downloadapi-fa8162c2100ef2198b38879cc888c178e4e29185.tar.gz
starting to structure cache checking for requests
Diffstat (limited to 'cache.go')
-rw-r--r--cache.go30
1 files changed, 27 insertions, 3 deletions
diff --git a/cache.go b/cache.go
index e26eed3..b15bb50 100644
--- a/cache.go
+++ b/cache.go
@@ -3,6 +3,7 @@ package main
 import (
 	"io/ioutil"
 	"log"
+	"strings"
 	"sync"
 	"time"
 )
@@ -27,9 +28,22 @@ var cache = &cacheWrapper{
 // Wraps the two cache-checking functions.
 // One for /, the other for various requests.
 func (cache *cacheWrapper) bap(requestPath string) {
-	switch requestPath {
-	case "/":
+	if requestPath == "/" {
 		bapIndex()
+		return
+	}
+	split := strings.Split(requestPath[1:], "/")
+	switch split[1] {
+	case "osversion":
+		bapOSVersion(split[0])
+	case "pkgs":
+		bapPkgs(split[0])
+	case "uptime":
+		bapUptime(split[0])
+	case "usercount":
+		bapUserCount(split[0])
+	case "users":
+		bapUsers(split[0])
 	default:
 	}
 }
@@ -66,6 +80,16 @@ func bapIndex() {
 
 	cache.pages["/"] = &page{
 		raw:     bytes,
-		expires: time.Now().Add(5 * time.Minute),
+		expires: time.Now().Add(1 * time.Minute),
 	}
 }
+
+func bapOSVersion(format string) {
+
+}
+
+func bapPkgs(format string)      {}
+func bapQuery(format string)     {}
+func bapUptime(format string)    {}
+func bapUserCount(format string) {}
+func bapUsers(format string)     {}