summaryrefslogtreecommitdiffstats
path: root/modules/web
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2023-07-21 06:43:49 +0800
committerGitHub <noreply@github.com>2023-07-21 00:43:49 +0200
commit9b25bfa8f4b6faf1b9799629db485c7d0e77ccd6 (patch)
treef6392c9938ae6b69fe454f9281dd192ce3fb3116 /modules/web
parentd12ba978a70fab41aac47c2e16a48d0d8f82a17e (diff)
downloadgitea-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 'modules/web')
-rw-r--r--modules/web/route.go23
1 files changed, 9 insertions, 14 deletions
diff --git a/modules/web/route.go b/modules/web/route.go
index dc87e112ec..c24c8f4d67 100644
--- a/modules/web/route.go
+++ b/modules/web/route.go
@@ -101,7 +101,7 @@ func (r *Route) wrapMiddlewareAndHandler(h []any) ([]func(http.Handler) http.Han
return middlewares, handlerFunc
}
-func (r *Route) Methods(method, pattern string, h []any) {
+func (r *Route) Methods(method, pattern string, h ...any) {
middlewares, handlerFunc := r.wrapMiddlewareAndHandler(h)
fullPattern := r.getPattern(pattern)
if strings.Contains(method, ",") {
@@ -126,49 +126,44 @@ func (r *Route) Any(pattern string, h ...any) {
r.R.With(middlewares...).HandleFunc(r.getPattern(pattern), handlerFunc)
}
-// RouteMethods delegate special methods, it is an alias of "Methods", while the "pattern" is the first parameter
-func (r *Route) RouteMethods(pattern, methods string, h ...any) {
- r.Methods(methods, pattern, h)
-}
-
// Delete delegate delete method
func (r *Route) Delete(pattern string, h ...any) {
- r.Methods("DELETE", pattern, h)
+ r.Methods("DELETE", pattern, h...)
}
// Get delegate get method
func (r *Route) Get(pattern string, h ...any) {
- r.Methods("GET", pattern, h)
+ r.Methods("GET", pattern, h...)
}
// GetOptions delegate get and options method
func (r *Route) GetOptions(pattern string, h ...any) {
- r.Methods("GET,OPTIONS", pattern, h)
+ r.Methods("GET,OPTIONS", pattern, h...)
}
// PostOptions delegate post and options method
func (r *Route) PostOptions(pattern string, h ...any) {
- r.Methods("POST,OPTIONS", pattern, h)
+ r.Methods("POST,OPTIONS", pattern, h...)
}
// Head delegate head method
func (r *Route) Head(pattern string, h ...any) {
- r.Methods("HEAD", pattern, h)
+ r.Methods("HEAD", pattern, h...)
}
// Post delegate post method
func (r *Route) Post(pattern string, h ...any) {
- r.Methods("POST", pattern, h)
+ r.Methods("POST", pattern, h...)
}
// Put delegate put method
func (r *Route) Put(pattern string, h ...any) {
- r.Methods("PUT", pattern, h)
+ r.Methods("PUT", pattern, h...)
}
// Patch delegate patch method
func (r *Route) Patch(pattern string, h ...any) {
- r.Methods("PATCH", pattern, h)
+ r.Methods("PATCH", pattern, h...)
}
// ServeHTTP implements http.Handler