aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-01-30 16:55:53 +0800
committerGitHub <noreply@github.com>2021-01-30 10:55:53 +0200
commit5e20fd6dbf52ede60ed9ac7944db0d3f6769cf86 (patch)
tree519259f05f7e7fc4dd1df4da521e000ce469567b /routers
parent0e0424c8ecaf6fa3cdd1fcfc154f188014c63dd8 (diff)
downloadgitea-5e20fd6dbf52ede60ed9ac7944db0d3f6769cf86.tar.gz
gitea-5e20fd6dbf52ede60ed9ac7944db0d3f6769cf86.zip
Move middlewares to web/middleware (#14480)
Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'routers')
-rw-r--r--routers/install.go8
-rw-r--r--routers/repo/pull.go4
-rw-r--r--routers/routes/base.go4
-rw-r--r--routers/routes/install.go4
-rw-r--r--routers/routes/web.go2
5 files changed, 11 insertions, 11 deletions
diff --git a/routers/install.go b/routers/install.go
index da2631931e..69ae428a54 100644
--- a/routers/install.go
+++ b/routers/install.go
@@ -20,12 +20,12 @@ import (
"code.gitea.io/gitea/modules/generate"
"code.gitea.io/gitea/modules/graceful"
"code.gitea.io/gitea/modules/log"
- "code.gitea.io/gitea/modules/middlewares"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/templates"
"code.gitea.io/gitea/modules/user"
"code.gitea.io/gitea/modules/util"
"code.gitea.io/gitea/modules/web"
+ "code.gitea.io/gitea/modules/web/middleware"
"gitea.com/go-chi/session"
"gopkg.in/ini.v1"
@@ -47,11 +47,11 @@ func InstallInit(next http.Handler) http.Handler {
_ = rnd.HTML(resp, 200, string(tplPostInstall), nil)
return
}
- var locale = middlewares.Locale(resp, req)
+ var locale = middleware.Locale(resp, req)
var startTime = time.Now()
var ctx = context.Context{
Resp: context.NewResponse(resp),
- Flash: &middlewares.Flash{},
+ Flash: &middleware.Flash{},
Locale: locale,
Render: rnd,
Session: session.GetSession(req),
@@ -143,7 +143,7 @@ func Install(ctx *context.Context) {
form.DefaultEnableTimetracking = setting.Service.DefaultEnableTimetracking
form.NoReplyAddress = setting.Service.NoReplyAddress
- middlewares.AssignForm(form, ctx.Data)
+ middleware.AssignForm(form, ctx.Data)
ctx.HTML(200, tplInstall)
}
diff --git a/routers/repo/pull.go b/routers/repo/pull.go
index 1862c15f43..6986002102 100644
--- a/routers/repo/pull.go
+++ b/routers/repo/pull.go
@@ -21,7 +21,6 @@ import (
auth "code.gitea.io/gitea/modules/forms"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
- "code.gitea.io/gitea/modules/middlewares"
"code.gitea.io/gitea/modules/notification"
repo_module "code.gitea.io/gitea/modules/repository"
"code.gitea.io/gitea/modules/setting"
@@ -29,6 +28,7 @@ import (
"code.gitea.io/gitea/modules/upload"
"code.gitea.io/gitea/modules/util"
"code.gitea.io/gitea/modules/web"
+ "code.gitea.io/gitea/modules/web/middleware"
"code.gitea.io/gitea/routers/utils"
"code.gitea.io/gitea/services/gitdiff"
pull_service "code.gitea.io/gitea/services/pull"
@@ -989,7 +989,7 @@ func CompareAndPullRequestPost(ctx *context.Context) {
}
if ctx.HasError() {
- middlewares.AssignForm(form, ctx.Data)
+ middleware.AssignForm(form, ctx.Data)
// This stage is already stop creating new pull request, so it does not matter if it has
// something to compare or not.
diff --git a/routers/routes/base.go b/routers/routes/base.go
index 4efb7f01d5..12a35936b1 100644
--- a/routers/routes/base.go
+++ b/routers/routes/base.go
@@ -18,10 +18,10 @@ import (
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/httpcache"
"code.gitea.io/gitea/modules/log"
- "code.gitea.io/gitea/modules/middlewares"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/storage"
"code.gitea.io/gitea/modules/templates"
+ "code.gitea.io/gitea/modules/web/middleware"
"gitea.com/go-chi/session"
)
@@ -153,7 +153,7 @@ func Recovery() func(next http.Handler) http.Handler {
return
}
- var lc = middlewares.Locale(w, req)
+ var lc = middleware.Locale(w, req)
var store = dataStore{
Data: templates.Vars{
"Language": lc.Language(),
diff --git a/routers/routes/install.go b/routers/routes/install.go
index 0dc066d600..fea396bc26 100644
--- a/routers/routes/install.go
+++ b/routers/routes/install.go
@@ -11,11 +11,11 @@ import (
"code.gitea.io/gitea/modules/forms"
"code.gitea.io/gitea/modules/log"
- "code.gitea.io/gitea/modules/middlewares"
"code.gitea.io/gitea/modules/public"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/templates"
"code.gitea.io/gitea/modules/web"
+ "code.gitea.io/gitea/modules/web/middleware"
"code.gitea.io/gitea/routers"
"gitea.com/go-chi/session"
@@ -46,7 +46,7 @@ func installRecovery() func(next http.Handler) http.Handler {
combinedErr := fmt.Sprintf("PANIC: %v\n%s", err, string(log.Stack(2)))
log.Error("%v", combinedErr)
- lc := middlewares.Locale(w, req)
+ lc := middleware.Locale(w, req)
var store = dataStore{
Data: templates.Vars{
"Language": lc.Language(),
diff --git a/routers/routes/web.go b/routers/routes/web.go
index 03555e3d54..f2b68aa10a 100644
--- a/routers/routes/web.go
+++ b/routers/routes/web.go
@@ -247,7 +247,7 @@ func RegisterRoutes(m *web.Route) {
}
}
- // FIXME: not all routes need go through same middlewares.
+ // FIXME: not all routes need go through same middleware.
// Especially some AJAX requests, we can reduce middleware number to improve performance.
// Routers.
// for health check