Fix error handling in renderStatic #64
No reviewers
Labels
No Label
bug
feature
good-beginner-bug
needs-test
question
wontfix
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: electricdusk/rushlink#64
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "issue-60"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
In
renderStatic
,modTime
should be set to the file's mod time if it exists. If the file does not exist,renderStatic
shouldmodTime
uninitialized,404 Not Found
error.Fixes #60.
@ -58,3 +58,3 @@
rootURL: rootURL,
}
return CreateMainRouter(&rl), &rl
return CreateMainRouter(&rl, true), &rl
(see comment below on the use of
debug
as a function parameter)@ -40,6 +41,7 @@ func (rl *rushlink) recoveryMiddleware(next http.Handler) http.Handler {
}()
if err := recover(); err != nil {
w.WriteHeader(500)
Can we definitively state that
panic()
s are caused due to errors on the server side?Yes.
panic
s during runtime should always indicate a bug.@ -81,3 +83,3 @@
// CreateMainRouter creates the main Gorilla router for the application.
func CreateMainRouter(rl *rushlink) *mux.Router {
func CreateMainRouter(rl *rushlink, debug bool) *mux.Router {
Instead of adding a debug parameter here, would it make sense to set
router.Use(rl.recoveryMiddleware)
insideTestIssue60
?And, if we want debugging options, this should be a globally configurable option, instead of a function parameter.
So you mean, as a global variable? So in this case,
debug
describes that the panic recovery middleware should be disabled, because otherwise we cannot run the tests. We could also change the namedebug
tonoPanicMiddleware
.What kind of solution would be good here?
@ -120,3 +124,3 @@
srv := &http.Server{
Handler: CreateMainRouter(&rl),
Handler: CreateMainRouter(&rl, false),
(see comment above on the use of
debug
as a function parameter)