Updated transitive dependencies
This commit is contained in:
parent
34cc53338f
commit
cd9443a64b
|
@ -26,9 +26,16 @@ var (
|
|||
)
|
||||
|
||||
func notFound(w http.ResponseWriter, r *http.Request, path string) error {
|
||||
startTime := time.Now()
|
||||
if Verbose {
|
||||
fmt.Printf("%s | ERROR: Unavailable file %s requested by %s\n",
|
||||
time.Now().Format(logDate),
|
||||
path,
|
||||
r.RemoteAddr,
|
||||
)
|
||||
}
|
||||
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
|
||||
w.Header().Add("Content-Type", "text/html")
|
||||
|
||||
nonce := types.GetNonce()
|
||||
|
@ -40,19 +47,16 @@ func notFound(w http.ResponseWriter, r *http.Request, path string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if Verbose {
|
||||
fmt.Printf("%s | ERROR: Unavailable file %s requested by %s\n",
|
||||
startTime.Format(logDate),
|
||||
path,
|
||||
r.RemoteAddr,
|
||||
)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func serverError(w http.ResponseWriter, r *http.Request, i interface{}) {
|
||||
startTime := time.Now()
|
||||
if Verbose {
|
||||
fmt.Printf("%s | ERROR: Invalid request for %s from %s\n",
|
||||
time.Now().Format(logDate),
|
||||
r.URL.Path,
|
||||
r.RemoteAddr)
|
||||
}
|
||||
|
||||
w.Header().Add("Content-Type", "text/html")
|
||||
|
||||
|
@ -62,12 +66,6 @@ func serverError(w http.ResponseWriter, r *http.Request, i interface{}) {
|
|||
|
||||
io.WriteString(w, gohtml.Format(newPage("Server Error", "An error has occurred. Please try again.", nonce)))
|
||||
|
||||
if Verbose {
|
||||
fmt.Printf("%s | ERROR: Invalid request for %s from %s\n",
|
||||
startTime.Format(logDate),
|
||||
r.URL.Path,
|
||||
r.RemoteAddr)
|
||||
}
|
||||
}
|
||||
|
||||
func serverErrorHandler() func(http.ResponseWriter, *http.Request, interface{}) {
|
||||
|
|
|
@ -522,7 +522,7 @@ func validatePaths(args []string, formats types.Types) ([]string, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
pathMatches := (args[i] == path)
|
||||
pathMatches := args[i] == path
|
||||
|
||||
hasSupportedFiles, err := hasSupportedFiles(path, formats)
|
||||
if err != nil {
|
||||
|
|
18
cmd/index.go
18
cmd/index.go
|
@ -191,21 +191,21 @@ func (index *fileIndex) Import(path string, errorChannel chan<- error) {
|
|||
}
|
||||
}
|
||||
|
||||
func rebuildIndex(args []string, index *fileIndex, formats types.Types, encoder *zstd.Encoder, errorChannel chan<- error) {
|
||||
func rebuildIndex(paths []string, index *fileIndex, formats types.Types, encoder *zstd.Encoder, errorChannel chan<- error) {
|
||||
index.clear()
|
||||
|
||||
fileList(args, &filters{}, "", index, formats, encoder, errorChannel)
|
||||
fileList(paths, &filters{}, "", index, formats, encoder, errorChannel)
|
||||
}
|
||||
|
||||
func importIndex(args []string, index *fileIndex, formats types.Types, encoder *zstd.Encoder, errorChannel chan<- error) {
|
||||
func importIndex(paths []string, index *fileIndex, formats types.Types, encoder *zstd.Encoder, errorChannel chan<- error) {
|
||||
if IndexFile != "" {
|
||||
index.Import(IndexFile, errorChannel)
|
||||
}
|
||||
|
||||
fileList(args, &filters{}, "", index, formats, encoder, errorChannel)
|
||||
fileList(paths, &filters{}, "", index, formats, encoder, errorChannel)
|
||||
}
|
||||
|
||||
func serveIndex(args []string, index *fileIndex, errorChannel chan<- error) httprouter.Handle {
|
||||
func serveIndex(index *fileIndex, errorChannel chan<- error) httprouter.Handle {
|
||||
return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
|
||||
startTime := time.Now()
|
||||
|
||||
|
@ -246,7 +246,7 @@ func serveIndex(args []string, index *fileIndex, errorChannel chan<- error) http
|
|||
}
|
||||
}
|
||||
|
||||
func serveIndexRebuild(args []string, index *fileIndex, formats types.Types, encoder *zstd.Encoder, errorChannel chan<- error) httprouter.Handle {
|
||||
func serveIndexRebuild(paths []string, index *fileIndex, formats types.Types, encoder *zstd.Encoder, errorChannel chan<- error) httprouter.Handle {
|
||||
return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
|
||||
if Verbose {
|
||||
fmt.Printf("%s | SERVE: Index rebuild requested by %s\n",
|
||||
|
@ -258,7 +258,7 @@ func serveIndexRebuild(args []string, index *fileIndex, formats types.Types, enc
|
|||
|
||||
w.Header().Set("Content-Type", "text/plain;charset=UTF-8")
|
||||
|
||||
rebuildIndex(args, index, formats, encoder, errorChannel)
|
||||
rebuildIndex(paths, index, formats, encoder, errorChannel)
|
||||
|
||||
_, err := w.Write([]byte("Ok\n"))
|
||||
if err != nil {
|
||||
|
@ -269,7 +269,7 @@ func serveIndexRebuild(args []string, index *fileIndex, formats types.Types, enc
|
|||
}
|
||||
}
|
||||
|
||||
func registerIndexInterval(args []string, index *fileIndex, formats types.Types, encoder *zstd.Encoder, quit <-chan struct{}, errorChannel chan<- error) {
|
||||
func registerIndexInterval(paths []string, index *fileIndex, formats types.Types, encoder *zstd.Encoder, quit <-chan struct{}, errorChannel chan<- error) {
|
||||
interval, err := time.ParseDuration(IndexInterval)
|
||||
if err != nil {
|
||||
errorChannel <- err
|
||||
|
@ -287,7 +287,7 @@ func registerIndexInterval(args []string, index *fileIndex, formats types.Types,
|
|||
fmt.Printf("%s | INDEX: Started scheduled index rebuild\n", time.Now().Format(logDate))
|
||||
}
|
||||
|
||||
rebuildIndex(args, index, formats, encoder, errorChannel)
|
||||
rebuildIndex(paths, index, formats, encoder, errorChannel)
|
||||
case <-quit:
|
||||
ticker.Stop()
|
||||
|
||||
|
|
|
@ -76,10 +76,10 @@ func serveMediaTypes(formats types.Types, available bool, errorChannel chan<- er
|
|||
}
|
||||
}
|
||||
|
||||
func registerAPIHandlers(mux *httprouter.Router, args []string, index *fileIndex, formats types.Types, encoder *zstd.Encoder, errorChannel chan<- error) {
|
||||
func registerAPIHandlers(mux *httprouter.Router, paths []string, index *fileIndex, formats types.Types, encoder *zstd.Encoder, errorChannel chan<- error) {
|
||||
if Index {
|
||||
mux.GET(Prefix+AdminPrefix+"/index", serveIndex(args, index, errorChannel))
|
||||
mux.POST(Prefix+AdminPrefix+"/index/rebuild", serveIndexRebuild(args, index, formats, encoder, errorChannel))
|
||||
mux.GET(Prefix+AdminPrefix+"/index", serveIndex(index, errorChannel))
|
||||
mux.POST(Prefix+AdminPrefix+"/index/rebuild", serveIndexRebuild(paths, index, formats, encoder, errorChannel))
|
||||
}
|
||||
|
||||
mux.GET(Prefix+AdminPrefix+"/extensions/available", serveExtensions(formats, true, errorChannel))
|
||||
|
|
|
@ -594,14 +594,14 @@ func ServePage(args []string) error {
|
|||
defer close(quit)
|
||||
|
||||
if API {
|
||||
registerAPIHandlers(mux, args, index, formats, encoder, errorChannel)
|
||||
registerAPIHandlers(mux, paths, index, formats, encoder, errorChannel)
|
||||
}
|
||||
|
||||
if Index {
|
||||
importIndex(paths, index, formats, encoder, errorChannel)
|
||||
|
||||
if IndexInterval != "" {
|
||||
registerIndexInterval(args, index, formats, encoder, quit, errorChannel)
|
||||
registerIndexInterval(paths, index, formats, encoder, quit, errorChannel)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue