diff options
author | 6543 <6543@obermui.de> | 2021-08-11 17:08:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-11 18:08:52 +0300 |
commit | f1a810e0901b80eb6bc21103434fc0737af17eaa (patch) | |
tree | 9656d780cf19fd745f41eef0012701458aa271c4 /routers/web/user | |
parent | 2d25b7d44bedf8f17cc2b49f39d1cee662b199a5 (diff) | |
download | gitea-f1a810e0901b80eb6bc21103434fc0737af17eaa.tar.gz gitea-f1a810e0901b80eb6bc21103434fc0737af17eaa.zip |
Related refactors to ctx.FormX functions (#16567)
* use FormTrim if posible
* speedup goGet
* only convert if nessesary
Diffstat (limited to 'routers/web/user')
-rw-r--r-- | routers/web/user/auth.go | 3 | ||||
-rw-r--r-- | routers/web/user/home.go | 2 | ||||
-rw-r--r-- | routers/web/user/notification.go | 9 | ||||
-rw-r--r-- | routers/web/user/profile.go | 2 |
4 files changed, 7 insertions, 9 deletions
diff --git a/routers/web/user/auth.go b/routers/web/user/auth.go index a9e60bb07c..313a583004 100644 --- a/routers/web/user/auth.go +++ b/routers/web/user/auth.go @@ -1491,8 +1491,7 @@ func ForgotPasswd(ctx *context.Context) { return } - email := ctx.FormString("email") - ctx.Data["Email"] = email + ctx.Data["Email"] = ctx.FormString("email") ctx.Data["IsResetRequest"] = true ctx.HTML(http.StatusOK, tplForgotPassword) diff --git a/routers/web/user/home.go b/routers/web/user/home.go index 285f1ff367..397850f18b 100644 --- a/routers/web/user/home.go +++ b/routers/web/user/home.go @@ -204,7 +204,7 @@ func Milestones(ctx *context.Context) { isShowClosed = ctx.FormString("state") == "closed" sortType = ctx.FormString("sort") page = ctx.FormInt("page") - keyword = strings.Trim(ctx.FormString("q"), " ") + keyword = ctx.FormTrim("q") ) if page <= 1 { diff --git a/routers/web/user/notification.go b/routers/web/user/notification.go index bc017db9d4..a444669b74 100644 --- a/routers/web/user/notification.go +++ b/routers/web/user/notification.go @@ -8,7 +8,6 @@ import ( "errors" "fmt" "net/http" - "strconv" "strings" "code.gitea.io/gitea/models" @@ -59,7 +58,7 @@ func Notifications(c *context.Context) { func getNotifications(c *context.Context) { var ( - keyword = strings.Trim(c.FormString("q"), " ") + keyword = c.FormTrim("q") status models.NotificationStatus page = c.FormInt("page") perPage = c.FormInt("perPage") @@ -144,9 +143,9 @@ func getNotifications(c *context.Context) { // NotificationStatusPost is a route for changing the status of a notification func NotificationStatusPost(c *context.Context) { var ( - notificationID, _ = strconv.ParseInt(c.Req.PostFormValue("notification_id"), 10, 64) - statusStr = c.Req.PostFormValue("status") - status models.NotificationStatus + notificationID = c.FormInt64("notification_id") + statusStr = c.FormString("status") + status models.NotificationStatus ) switch statusStr { diff --git a/routers/web/user/profile.go b/routers/web/user/profile.go index e6a8e5b5a8..c1d787a860 100644 --- a/routers/web/user/profile.go +++ b/routers/web/user/profile.go @@ -187,7 +187,7 @@ func Profile(ctx *context.Context) { orderBy = models.SearchOrderByRecentUpdated } - keyword := strings.Trim(ctx.FormString("q"), " ") + keyword := ctx.FormTrim("q") ctx.Data["Keyword"] = keyword switch tab { case "followers": |