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)