fix: use single Preferences handler with method check instead of dead POST route
This commit is contained in:
parent
70818558cd
commit
0afcf509c3
2 changed files with 7 additions and 14 deletions
|
|
@ -143,25 +143,19 @@ func (h *Handler) Autocompleter(w http.ResponseWriter, r *http.Request) {
|
|||
_ = json.NewEncoder(w).Encode(suggestions)
|
||||
}
|
||||
|
||||
// Preferences renders the preferences page.
|
||||
// Preferences handles GET and POST for the preferences page.
|
||||
func (h *Handler) Preferences(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Path != "/preferences" {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
if r.Method == "POST" {
|
||||
// Preferences are stored in localStorage on the client via JavaScript.
|
||||
// This handler exists only for form submission completeness.
|
||||
http.Redirect(w, r, "/preferences", http.StatusFound)
|
||||
return
|
||||
}
|
||||
if err := views.RenderPreferences(w, h.sourceURL); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
// PreferencesPOST handles form submission from the preferences page.
|
||||
// NOTE: This is a no-op. All preferences are stored in localStorage on the client
|
||||
// via JavaScript. This handler exists only for form submission completeness (e.g.,
|
||||
// if a form POSTs without JS). The JavaScript in settings.js handles all saves.
|
||||
func (h *Handler) PreferencesPOST(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Path != "/preferences" {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
http.Redirect(w, r, "/preferences", http.StatusFound)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue