-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is a large change that primarily moves HTML rendering and display logic from backend to frontend (#67). Previously, the HTML for displaying updates was rendered on backend and streamed to browser. This worked surprisingly well and got me far, but in order to be able to have more fine grained control over frontend details, it was no longer viable to keep doing that. Now, the HTML is fully rendered on frontend, and most of the logic resides on the frontend. The backend provides services to the frontend. See issue #67 for full rationale why this is desired. Implement a long-standing feature request of having an "Update All" button (#6). This is both made possible and easy thanks to the frontend HTML rendering. This change partially helps #63, but also enables potential future changes to help it even more. In general, the move to frontend HTML rendering will help potentially achieve some of enhancements described in #8. Close #66 by removing the popup altogether. It wasn't well implemented, so it's better to remove. In the future, a better replacement implementation of the notification (without the modal popup) can be considered. Resolves #67. Closes #66. Helps #63. Helps #8. Resolves #6.
- Loading branch information
Showing
14 changed files
with
1,002 additions
and
387 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"net/http" | ||
"os" | ||
|
||
"github.com/shurcooL/httperror" | ||
) | ||
|
||
// errorHandler factors error handling out of the HTTP handler. | ||
type errorHandler func(w http.ResponseWriter, req *http.Request) error | ||
|
||
func (h errorHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { | ||
err := h(w, req) | ||
if err == nil { | ||
// Do nothing. | ||
return | ||
} | ||
if err, ok := httperror.IsMethod(err); ok { | ||
httperror.HandleMethod(w, err) | ||
return | ||
} | ||
if err, ok := httperror.IsRedirect(err); ok { | ||
http.Redirect(w, req, err.URL, http.StatusSeeOther) | ||
return | ||
} | ||
if err, ok := httperror.IsBadRequest(err); ok { | ||
httperror.HandleBadRequest(w, err) | ||
return | ||
} | ||
if err, ok := httperror.IsHTTP(err); ok { | ||
code := err.Code | ||
error := fmt.Sprintf("%d %s\n\n%v", code, http.StatusText(code), err) | ||
http.Error(w, error, code) | ||
return | ||
} | ||
if os.IsNotExist(err) { | ||
log.Println(err) | ||
http.Error(w, "404 Not Found\n\n"+err.Error(), http.StatusNotFound) | ||
return | ||
} | ||
if os.IsPermission(err) { | ||
log.Println(err) | ||
http.Error(w, "403 Forbidden\n\n"+err.Error(), http.StatusUnauthorized) | ||
return | ||
} | ||
|
||
log.Println(err) | ||
http.Error(w, "500 Internal Server Error\n\n"+err.Error(), http.StatusInternalServerError) | ||
} |
Oops, something went wrong.