Merge remote-tracking branch 'origin/master'

# Conflicts:
#	servlet/server.go
This commit is contained in:
dtookey 2022-11-16 11:12:20 -05:00
commit fd61f14365
3 changed files with 9 additions and 8 deletions

View File

@ -1,7 +1,6 @@
package servlet
import (
"encoding/json"
"fmt"
"geniuscartel.xyz/vinegar/vinegarUtil"
"log"
@ -73,7 +72,7 @@ func (s *VinegarServlet) ServeHTTP(w http.ResponseWriter, req *http.Request) {
return
}
}
s.SendError(w, 404, "Couldn't find your content.")
s.SendError(w, req, 404, "Couldn't find your content.", errors.New("failed to match route for ["+path+"]"))
}
func (s *VinegarServlet) Start() {
@ -96,8 +95,9 @@ func (r *VinegarRoute) Announce() {
log.Printf("Added route for [%s]\n", r.Pattern.String())
}
func (s *VinegarServlet) SendError(w http.ResponseWriter, code int, msg string) {
fmt.Printf("Reached SendError. Rendering template for code %d with message: %s\n", code, msg)
func (s *VinegarServlet) SendError(w http.ResponseWriter, req *http.Request, code int, msg string, aErr error) {
fmt.Printf("[%d][%s]. Rendering template for code %d with message: %s\n", code, req.URL.Path, code, msg)
fmt.Println(aErr)
tmpl, exists := s.ErrorRoutes[code]
if exists {
tmpl.TemplateManager.AddMixin("code", strconv.Itoa(code))

View File

@ -1,6 +1,7 @@
package servlet
import (
"errors"
util "geniuscartel.xyz/vinegar/vinegarUtil"
"net/http"
"path"
@ -73,7 +74,7 @@ func createSingleFileServletFunction(route *FileRoute) VinegarHandlerFunction {
}
if !exists {
route.srv.SendError(w, 404, "File not found.")
route.srv.SendError(w, req, 404, "File not found.", errors.New("could not find file: "+route.fileRoot))
return
}
@ -114,7 +115,7 @@ func createCompressibleFileServletFunction(route *FileRoute, basePattern string,
return
}
} else {
route.srv.SendError(w, 404, "Couldn't find your content.")
route.srv.SendError(w, req, 404, "Couldn't find your content.", errors.New("could not find valid file at ["+resourcePath+"]"))
return
}
}
@ -154,7 +155,7 @@ func createUncompressedFileServletFunction(route *FileRoute, basePattern string,
return
} else {
route.srv.SendError(w, 404, "Couldn't find your content.")
route.srv.SendError(w, req, 404, "Couldn't find your content.", errors.New("could not find file for ["+stub+"]"))
}
}
return fun

View File

@ -9,7 +9,7 @@ import (
)
const (
DefaultCacheTimeInMinutes = 15
DefaultCacheTimeInMinutes = 5
)
type (