mirror of
https://github.com/miniflux/v2.git
synced 2025-08-01 17:38:37 +00:00
Refactor HTTP response builder
This commit is contained in:
parent
ddfe969d6c
commit
1f58b37a5e
94 changed files with 1701 additions and 644 deletions
|
@ -2,16 +2,15 @@
|
|||
// Use of this source code is governed by the Apache 2.0
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package ui // import "miniflux.app/ui"
|
||||
package ui // import "miniflux.app/ui"
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"miniflux.app/http/response"
|
||||
"miniflux.app/http/request"
|
||||
"miniflux.app/http/response/html"
|
||||
"miniflux.app/http/request"
|
||||
"miniflux.app/http/route"
|
||||
"miniflux.app/locale"
|
||||
"miniflux.app/ui/form"
|
||||
|
@ -24,13 +23,13 @@ func (c *Controller) UpdateIntegration(w http.ResponseWriter, r *http.Request) {
|
|||
sess := session.New(c.store, request.SessionID(r))
|
||||
user, err := c.store.UserByID(request.UserID(r))
|
||||
if err != nil {
|
||||
html.ServerError(w, err)
|
||||
html.ServerError(w, r, err)
|
||||
return
|
||||
}
|
||||
|
||||
integration, err := c.store.Integration(user.ID)
|
||||
if err != nil {
|
||||
html.ServerError(w, err)
|
||||
html.ServerError(w, r, err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -39,7 +38,7 @@ func (c *Controller) UpdateIntegration(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
if integration.FeverUsername != "" && c.store.HasDuplicateFeverUsername(user.ID, integration.FeverUsername) {
|
||||
sess.NewFlashErrorMessage(printer.Printf("error.duplicate_fever_username"))
|
||||
response.Redirect(w, r, route.Path(c.router, "integrations"))
|
||||
html.Redirect(w, r, route.Path(c.router, "integrations"))
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -51,10 +50,10 @@ func (c *Controller) UpdateIntegration(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
err = c.store.UpdateIntegration(integration)
|
||||
if err != nil {
|
||||
html.ServerError(w, err)
|
||||
html.ServerError(w, r, err)
|
||||
return
|
||||
}
|
||||
|
||||
sess.NewFlashMessage(printer.Printf("alert.prefs_saved"))
|
||||
response.Redirect(w, r, route.Path(c.router, "integrations"))
|
||||
html.Redirect(w, r, route.Path(c.router, "integrations"))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue