From 2a057bac1efb7c6175331ee4fd72a15c0df01422 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sun, 09 Mar 2025 16:25:28 +0800 Subject: [PATCH] gc: Add a garbage collection button --- http_handle_gc.go | 14 ++++++++++++++ http_server.go | 3 +++ templates/index.tmpl | 3 +++ diff --git a/http_handle_gc.go b/http_handle_gc.go new file mode 100644 index 0000000000000000000000000000000000000000..3f7717cfed73a527d81b3f08f4dc0aebd21602b6 --- /dev/null +++ b/http_handle_gc.go @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: AGPL-3.0-only +// SPDX-FileContributor: Runxi Yu + +package main + +import ( + "net/http" + "runtime" +) + +func handle_gc(w http.ResponseWriter, r *http.Request, params map[string]any) { + runtime.GC() + http.Redirect(w, r, "/", http.StatusSeeOther) +} diff --git a/http_server.go b/http_server.go index 1b9bef68bffb83d13150201dcf6c6e9342417c1b..f2238d832337ea1283011e045d1f80371e2cd5e6 100644 --- a/http_server.go +++ b/http_server.go @@ -78,6 +78,9 @@ return case "users": handle_users(w, r, params) return + case "gc": + handle_gc(w, r, params) + return default: http.Error(w, fmt.Sprintf("Unknown system module type: %s", segments[1]), http.StatusNotFound) return diff --git a/templates/index.tmpl b/templates/index.tmpl index 3bef7b06191ad2c60a9f652977fe16e40b42e68b..2aa5729ac033d35d300764e8e1fef837710fad53 100644 --- a/templates/index.tmpl +++ b/templates/index.tmpl @@ -56,6 +56,9 @@ + -- 2.48.1