diff options
author | Ben Morrison <ben@gbmor.dev> | 2020-05-07 19:33:56 -0400 |
---|---|---|
committer | Ben Morrison <ben@gbmor.dev> | 2020-05-07 19:33:56 -0400 |
commit | fa8162c2100ef2198b38879cc888c178e4e29185 (patch) | |
tree | 92e5c04c293a9d2e3b17bd3c8531afa58802f246 | |
parent | 281444e000918aa20d486ad71f62ff22afd42860 (diff) | |
download | api-fa8162c2100ef2198b38879cc888c178e4e29185.tar.gz |
starting to structure cache checking for requests
-rw-r--r-- | cache.go | 30 |
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) {} |