diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2023-07-21 06:43:49 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-21 00:43:49 +0200 |
commit | 9b25bfa8f4b6faf1b9799629db485c7d0e77ccd6 (patch) | |
tree | f6392c9938ae6b69fe454f9281dd192ce3fb3116 /routers | |
parent | d12ba978a70fab41aac47c2e16a48d0d8f82a17e (diff) | |
download | gitea-9b25bfa8f4b6faf1b9799629db485c7d0e77ccd6.tar.gz gitea-9b25bfa8f4b6faf1b9799629db485c7d0e77ccd6.zip |
Remove redundant "RouteMethods" method (#26024)
The `RouteMethods` is mainly an alias for `Methods` with different
argument order.
Remove it to keep the "route.go" code clear
Diffstat (limited to 'routers')
-rw-r--r-- | routers/api/packages/api.go | 2 | ||||
-rw-r--r-- | routers/install/routes.go | 2 | ||||
-rw-r--r-- | routers/web/web.go | 16 |
3 files changed, 10 insertions, 10 deletions
diff --git a/routers/api/packages/api.go b/routers/api/packages/api.go index fa7f66f3ab..2ba35e2138 100644 --- a/routers/api/packages/api.go +++ b/routers/api/packages/api.go @@ -634,7 +634,7 @@ func ContainerRoutes() *web.Route { ) // Manual mapping of routes because {image} can contain slashes which chi does not support - r.RouteMethods("/*", "HEAD,GET,POST,PUT,PATCH,DELETE", func(ctx *context.Context) { + r.Methods("HEAD,GET,POST,PUT,PATCH,DELETE", "/*", func(ctx *context.Context) { path := ctx.Params("*") isHead := ctx.Req.Method == "HEAD" isGet := ctx.Req.Method == "GET" diff --git a/routers/install/routes.go b/routers/install/routes.go index f09a22b1e6..ce6d41b32d 100644 --- a/routers/install/routes.go +++ b/routers/install/routes.go @@ -20,7 +20,7 @@ import ( func Routes() *web.Route { base := web.NewRoute() base.Use(common.ProtocolMiddlewares()...) - base.RouteMethods("/assets/*", "GET, HEAD", public.AssetsHandlerFunc("/assets/")) + base.Methods("GET, HEAD", "/assets/*", public.AssetsHandlerFunc("/assets/")) r := web.NewRoute() r.Use(common.Sessioner(), Contexter()) diff --git a/routers/web/web.go b/routers/web/web.go index b4c0030ab7..8b9ecd5b8e 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -108,12 +108,12 @@ func Routes() *web.Route { routes := web.NewRoute() routes.Head("/", misc.DummyOK) // for health check - doesn't need to be passed through gzip handler - routes.RouteMethods("/assets/*", "GET, HEAD", CorsHandler(), public.AssetsHandlerFunc("/assets/")) - routes.RouteMethods("/avatars/*", "GET, HEAD", storageHandler(setting.Avatar.Storage, "avatars", storage.Avatars)) - routes.RouteMethods("/repo-avatars/*", "GET, HEAD", storageHandler(setting.RepoAvatar.Storage, "repo-avatars", storage.RepoAvatars)) - routes.RouteMethods("/apple-touch-icon.png", "GET, HEAD", misc.StaticRedirect("/assets/img/apple-touch-icon.png")) - routes.RouteMethods("/apple-touch-icon-precomposed.png", "GET, HEAD", misc.StaticRedirect("/assets/img/apple-touch-icon.png")) - routes.RouteMethods("/favicon.ico", "GET, HEAD", misc.StaticRedirect("/assets/img/favicon.png")) + routes.Methods("GET, HEAD", "/assets/*", CorsHandler(), public.AssetsHandlerFunc("/assets/")) + routes.Methods("GET, HEAD", "/avatars/*", storageHandler(setting.Avatar.Storage, "avatars", storage.Avatars)) + routes.Methods("GET, HEAD", "/repo-avatars/*", storageHandler(setting.RepoAvatar.Storage, "repo-avatars", storage.RepoAvatars)) + routes.Methods("GET, HEAD", "/apple-touch-icon.png", misc.StaticRedirect("/assets/img/apple-touch-icon.png")) + routes.Methods("GET, HEAD", "/apple-touch-icon-precomposed.png", misc.StaticRedirect("/assets/img/apple-touch-icon.png")) + routes.Methods("GET, HEAD", "/favicon.ico", misc.StaticRedirect("/assets/img/favicon.png")) _ = templates.HTMLRenderer() @@ -129,7 +129,7 @@ func Routes() *web.Route { if setting.Service.EnableCaptcha { // The captcha http.Handler should only fire on /captcha/* so we can just mount this on that url - routes.RouteMethods("/captcha/*", "GET,HEAD", append(mid, captcha.Captchaer(context.GetImageCaptcha()))...) + routes.Methods("GET,HEAD", "/captcha/*", append(mid, captcha.Captchaer(context.GetImageCaptcha()))...) } if setting.HasRobotsTxt { @@ -773,7 +773,7 @@ func registerRoutes(m *web.Route) { addSettingVariablesRoutes() }, actions.MustEnableActions) - m.RouteMethods("/delete", "GET,POST", org.SettingsDelete) + m.Methods("GET,POST", "/delete", org.SettingsDelete) m.Group("/packages", func() { m.Get("", org.Packages) |