mirror of
https://github.com/miniflux/v2.git
synced 2025-09-15 18:57:04 +00:00
Refactor HTTP response builder
This commit is contained in:
parent
ddfe969d6c
commit
1f58b37a5e
94 changed files with 1701 additions and 644 deletions
|
@ -7,9 +7,8 @@ package ui // import "miniflux.app/ui"
|
|||
import (
|
||||
"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/integration/pocket"
|
||||
"miniflux.app/locale"
|
||||
|
@ -22,13 +21,13 @@ func (c *Controller) PocketAuthorize(w http.ResponseWriter, r *http.Request) {
|
|||
printer := locale.NewPrinter(request.UserLanguage(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,12 +38,12 @@ func (c *Controller) PocketAuthorize(w http.ResponseWriter, r *http.Request) {
|
|||
if err != nil {
|
||||
logger.Error("[Pocket:Authorize] %v", err)
|
||||
sess.NewFlashErrorMessage(printer.Printf("error.pocket_request_token"))
|
||||
response.Redirect(w, r, route.Path(c.router, "integrations"))
|
||||
html.Redirect(w, r, route.Path(c.router, "integrations"))
|
||||
return
|
||||
}
|
||||
|
||||
sess.SetPocketRequestToken(requestToken)
|
||||
response.Redirect(w, r, connector.AuthorizationURL(requestToken, redirectURL))
|
||||
html.Redirect(w, r, connector.AuthorizationURL(requestToken, redirectURL))
|
||||
}
|
||||
|
||||
// PocketCallback saves the personal access token after the authorization step.
|
||||
|
@ -54,13 +53,13 @@ func (c *Controller) PocketCallback(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -69,7 +68,7 @@ func (c *Controller) PocketCallback(w http.ResponseWriter, r *http.Request) {
|
|||
if err != nil {
|
||||
logger.Error("[Pocket:Callback] %v", err)
|
||||
sess.NewFlashErrorMessage(printer.Printf("error.pocket_access_token"))
|
||||
response.Redirect(w, r, route.Path(c.router, "integrations"))
|
||||
html.Redirect(w, r, route.Path(c.router, "integrations"))
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -78,10 +77,10 @@ func (c *Controller) PocketCallback(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.pocket_linked"))
|
||||
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