From d75188848a8181fcaa26e4a3e1932bf78b8ac08c Mon Sep 17 00:00:00 2001 From: Tyler Date: Mon, 10 Jan 2022 00:15:07 -0500 Subject: [PATCH] Add dl_map endpoint --- http.go | 11 +++++++++++ main.go | 1 + 2 files changed, 12 insertions(+) diff --git a/http.go b/http.go index bf73066..6f8c398 100644 --- a/http.go +++ b/http.go @@ -87,3 +87,14 @@ func reloadHandler(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusNotFound) } + +func dlMapHandler(w http.ResponseWriter, r *http.Request) { + if dlMap == nil { + w.WriteHeader(http.StatusNotFound) + return + } + + w.Header().Set("Content-Type", "application/json") + + json.NewEncoder(w).Encode(dlMap) +} diff --git a/main.go b/main.go index 4d5b408..cd9ce2d 100644 --- a/main.go +++ b/main.go @@ -124,6 +124,7 @@ func main() { mux.HandleFunc("/status", statusHandler) mux.HandleFunc("/mirrors", mirrorsHandler) mux.HandleFunc("/reload", reloadHandler) + mux.HandleFunc("/dl_map", dlMapHandler) mux.HandleFunc("/", RealIPMiddleware(redirectHandler)) http.ListenAndServe(viper.GetString("bind"), mux)