Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(286)

Unified Diff: appengine/cmd/milo/settings/settings.go

Issue 2043423004: Make HTTP middleware easier to use (Closed) Base URL: https://github.com/luci/luci-go@master
Patch Set: gaemiddleware: add middleware func for WithProd Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/cmd/milo/frontend/milo.go ('k') | appengine/cmd/milo/settings/themes.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/cmd/milo/settings/settings.go
diff --git a/appengine/cmd/milo/settings/settings.go b/appengine/cmd/milo/settings/settings.go
index d7fb7399be6c4f605603306a8383b8dbb479a508..fe04460cc61da16d4be492805136f807c8a37df2 100644
--- a/appengine/cmd/milo/settings/settings.go
+++ b/appengine/cmd/milo/settings/settings.go
@@ -3,27 +3,27 @@
// that can be found in the LICENSE file.
package settings
import (
"encoding/base64"
"encoding/json"
"fmt"
"net/http"
- "github.com/julienschmidt/httprouter"
"github.com/luci/gae/service/datastore"
"github.com/luci/luci-go/appengine/cmd/milo/model"
"github.com/luci/luci-go/appengine/cmd/milo/resp"
"github.com/luci/luci-go/server/auth"
"github.com/luci/luci-go/server/auth/identity"
"github.com/luci/luci-go/server/auth/xsrf"
+ "github.com/luci/luci-go/server/router"
"golang.org/x/net/context"
)
type updateReq struct {
Theme string
}
// GetTheme returns the chosen theme based on the current user.
func GetTheme(c context.Context, r *http.Request) Theme {
cfg := getUserSettings(c)
@@ -68,21 +68,23 @@ func getCookieSettings(c context.Context, r *http.Request) *model.UserConfig {
}
err = json.Unmarshal([]byte(s), &config)
if err != nil {
panic(err)
}
return &config
}
// ChangeSettings is invoked in a POST request to settings and changes either
// the user settings in the datastore, or the cookies if user is anon.
-func ChangeSettings(c context.Context, h http.ResponseWriter, r *http.Request, p httprouter.Params) {
+func ChangeSettings(ctx *router.Context) {
+ c, h, r := ctx.Context, ctx.Writer, ctx.Request
+
// First, check XSRF token.
err := xsrf.Check(c, r.FormValue("xsrf_token"))
if err != nil {
h.WriteHeader(http.StatusUnauthorized)
h.Write([]byte("Failed XSRF check."))
return
}
u := &updateReq{
Theme: r.FormValue("theme"),
« no previous file with comments | « appengine/cmd/milo/frontend/milo.go ('k') | appengine/cmd/milo/settings/themes.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698