From 8dae3865c04884ee7f4c1f4dd4ccc18e4f717147 Mon Sep 17 00:00:00 2001 From: Seednode Date: Fri, 28 Apr 2023 13:31:07 -0500 Subject: [PATCH] Renamed /_/index to /_/debug, and adjusted readme accordingly --- README.md | 6 +++--- cmd/root.go | 2 +- cmd/version.go | 2 +- cmd/web.go | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index bb59e5f..ac5fab0 100644 --- a/README.md +++ b/README.md @@ -83,9 +83,9 @@ If the `--stats` flag is passed, an additional endpoint, `/_/stats`, is register When accessed, this endpoint returns a JSON document listing every file served, along with the number of times it has been served, its filesize, and timestamps of when it was served. ## Debug -If the `-d|--debug` flag is passed, an additional endpoint, `/_/index`, is registered. +If the `-d|--debug` flag is passed, an additional endpoint, `/_/debug`, is registered. -When accessed, this endpoint returns a JSON document listing every file currently in the index. +When accessed, this endpoint returns a sorted JSON document listing every file currently in the index. This can prove useful when confirming whether the index is generated successfully, or whether a given file is in the index. ## Usage output ``` @@ -101,7 +101,7 @@ Available Commands: Flags: -c, --cache generate directory cache at startup --cache-file string path to optional persistent cache file - -d, --debug expose index endpoint + -d, --debug expose debug endpoint -f, --filter enable filtering -h, --help help for roulette -p, --port uint16 port to listen on (default 8080) diff --git a/cmd/root.go b/cmd/root.go index 161a9be..d8f836a 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -49,7 +49,7 @@ func Execute() { func init() { rootCmd.Flags().BoolVarP(&cache, "cache", "c", false, "generate directory cache at startup") rootCmd.Flags().StringVar(&cacheFile, "cache-file", "", "path to optional persistent cache file") - rootCmd.Flags().BoolVarP(&debug, "debug", "d", false, "expose index endpoint") + rootCmd.Flags().BoolVarP(&debug, "debug", "d", false, "expose debug endpoint") rootCmd.Flags().BoolVarP(&filtering, "filter", "f", false, "enable filtering") rootCmd.Flags().Uint16VarP(&port, "port", "p", 8080, "port to listen on") rootCmd.Flags().BoolVarP(&recursive, "recursive", "r", false, "recurse into subdirectories") diff --git a/cmd/version.go b/cmd/version.go index f37429d..e0b91d7 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -10,7 +10,7 @@ import ( "github.com/spf13/cobra" ) -var Version = "0.41.1" +var Version = "0.42.0" func init() { rootCmd.AddCommand(versionCmd) diff --git a/cmd/web.go b/cmd/web.go index e8431cb..1e795a1 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -646,7 +646,7 @@ func serveStatsHandler(args []string, stats *ServeStats) http.HandlerFunc { } } -func serveIndexHandler(args []string, index *Index) http.HandlerFunc { +func serveDebugHandler(args []string, index *Index) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) w.Header().Set("Content-Type", "application/json") @@ -667,7 +667,7 @@ func serveIndexHandler(args []string, index *Index) http.HandlerFunc { w.Write(response) if verbose { - fmt.Printf("%s | Served index page (%s) to %s in %s\n", + fmt.Printf("%s | Served debug page (%s) to %s in %s\n", startTime.Format(LogDate), humanReadableSize(len(response)), realIP(r), @@ -866,7 +866,7 @@ func ServePage(args []string) error { } if debug { - http.Handle("/_/index", serveIndexHandler(args, index)) + http.Handle("/_/debug", serveDebugHandler(args, index)) } err = http.ListenAndServe(":"+strconv.FormatInt(int64(port), 10), nil)