Renamed /_/index to /_/debug, and adjusted readme accordingly
This commit is contained in:
parent
84af467feb
commit
8dae3865c0
|
@ -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)
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var Version = "0.41.1"
|
||||
var Version = "0.42.0"
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(versionCmd)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue