Restructure endpoints to be more structured, bump major version

This commit is contained in:
Seednode 2023-10-09 10:13:15 -05:00
parent c6941f1336
commit 81d7e60d0c
5 changed files with 14 additions and 21 deletions

View File

@ -35,20 +35,20 @@ If the `-i|--indexing` flag is passed, all specified paths will be indexed on st
This will slightly increase the delay before the application begins responding to requests, but should significantly speed up subsequent requests.
The index can be regenerated at any time by accessing the `/rebuild_index` endpoint.
The index can be regenerated at any time by accessing the `/index/rebuild` endpoint.
If `--index-file` is set, the index will be loaded from the specified file on start, and written to the file whenever it is re-generated.
## Info
If the `-i|--info` flag is passed, six additional endpoints are registered.
The first of these—`/html` and `/json`—return the contents of the index, in HTML and JSON formats respectively.
The first of these—`/index/html` and `/index/json`—return the contents of the index, in HTML and JSON formats respectively.
If `--page-length` is also set, these can be viewed in paginated form by appending `/n`, e.g. `/html/5` for the fifth page.
If `--page-length` is also set, these can be viewed in paginated form by appending a page number, e.g. `/index/html/5` for the fifth page.
This can prove useful when confirming whether the index is generated successfully, or whether a given file is in the index.
The remaining four endpoints—`/available/extensions`, `/enabled/extensions`, `/available/types` and `/enabled/types`—return information about the registered file types.
The remaining four endpoints—`/extensions/available`, `/extensions/enabled`, `/types/available` and `/types/enabled`—return information about the registered file types.
## Refresh
If the `--refresh` flag is passed and a positive-value `refresh=<integer><unit>` query parameter is provided, the page will reload after that interval.

View File

@ -27,13 +27,6 @@ type regexes struct {
filename *regexp.Regexp
}
// type scanStats struct {
// filesMatched int
// filesSkipped int
// directoriesMatched int
// directoriesSkipped int
// }
type scanStatsChannels struct {
filesMatched chan int
filesSkipped chan int

View File

@ -178,7 +178,7 @@ func serveIndexRebuild(args []string, index *fileIndex, formats types.Types, err
}
func registerIndexHandlers(mux *httprouter.Router, args []string, index *fileIndex, formats types.Types, errorChannel chan<- error) error {
registerHandler(mux, Prefix+"/rebuild_index", serveIndexRebuild(args, index, formats, errorChannel))
registerHandler(mux, Prefix+"/index/rebuild", serveIndexRebuild(args, index, formats, errorChannel))
return nil
}

View File

@ -301,19 +301,19 @@ func serveEnabledMediaTypes(formats types.Types, errorChannel chan<- error) http
func registerInfoHandlers(mux *httprouter.Router, args []string, index *fileIndex, formats types.Types, errorChannel chan<- error) {
if Index {
registerHandler(mux, Prefix+"/html", serveIndexHtml(args, index, false))
registerHandler(mux, Prefix+"/index/html", serveIndexHtml(args, index, false))
if PageLength != 0 {
registerHandler(mux, Prefix+"/html/:page", serveIndexHtml(args, index, true))
registerHandler(mux, Prefix+"/index/html/:page", serveIndexHtml(args, index, true))
}
registerHandler(mux, Prefix+"/json", serveIndexJson(args, index, errorChannel))
registerHandler(mux, Prefix+"/index/json", serveIndexJson(args, index, errorChannel))
if PageLength != 0 {
registerHandler(mux, Prefix+"/json/:page", serveIndexJson(args, index, errorChannel))
registerHandler(mux, Prefix+"/index/json/:page", serveIndexJson(args, index, errorChannel))
}
}
registerHandler(mux, Prefix+"/available/extensions", serveAvailableExtensions(errorChannel))
registerHandler(mux, Prefix+"/enabled/extensions", serveEnabledExtensions(formats, errorChannel))
registerHandler(mux, Prefix+"/available/types", serveAvailableMediaTypes(errorChannel))
registerHandler(mux, Prefix+"/enabled/types", serveEnabledMediaTypes(formats, errorChannel))
registerHandler(mux, Prefix+"/extensions/available", serveAvailableExtensions(errorChannel))
registerHandler(mux, Prefix+"/extensions/enabled", serveEnabledExtensions(formats, errorChannel))
registerHandler(mux, Prefix+"/types/available", serveAvailableMediaTypes(errorChannel))
registerHandler(mux, Prefix+"/types/enabled", serveEnabledMediaTypes(formats, errorChannel))
}

View File

@ -12,7 +12,7 @@ import (
)
const (
ReleaseVersion string = "2.9.0"
ReleaseVersion string = "3.0.0"
)
var (