gitea/routers/web
wxiaoguang b9a97ccd0e
Refactor web route (#24080)
The old code is unnecessarily complex, and has many misuses.

Old code "wraps" a lot, wrap wrap wrap, it's difficult to understand
which kind of handler is used.

The new code uses a general approach, we do not need to write all kinds
of handlers into the "wrapper", do not need to wrap them again and
again.

New code, there are only 2 concepts:

1. HandlerProvider: `func (h any) (handlerProvider func (next)
http.Handler)`, it can be used as middleware
2. Use HandlerProvider to get the final HandlerFunc, and use it for
`r.Get()`


And we can decouple the route package from context package (see the
TODO).

# FAQ

## Is `reflect` safe?

Yes, all handlers are checked during startup, see the `preCheckHandler`
comment. If any handler is wrong, developers could know it in the first
time.

## Does `reflect` affect performance?

No. https://github.com/go-gitea/gitea/pull/24080#discussion_r1164825901

1. This reflect code only runs for each web handler call, handler is far
more slower: 10ms-50ms
2. The reflect is pretty fast (comparing to other code): 0.000265ms
3. XORM has more reflect operations already
2023-04-20 14:49:06 -04:00
..
admin Use auto-updating, natively hoverable, localized time elements (#23988) 2023-04-11 01:01:20 +02:00
auth Refactor cookie (#24107) 2023-04-13 15:45:33 -04:00
devtest Remove untranslatable on_date key (#24106) 2023-04-15 13:01:54 +02:00
events Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
explore Add ONLY_SHOW_RELEVANT_REPOS back, fix explore page bug, make code more strict (#23766) 2023-03-29 08:41:45 -05:00
feed User/Org Feed render description as per web (#23887) 2023-04-04 04:39:47 +01:00
healthcheck Refactor setting.Database.UseXXX to methods (#23354) 2023-03-07 18:51:06 +08:00
misc Introduce GitHub markdown editor, keep EasyMDE as fallback (#23876) 2023-04-03 18:06:57 +08:00
org Fix unclear "Owner" concept (#24233) 2023-04-20 19:33:30 +02:00
repo Fix issue attachment handling (#24202) 2023-04-20 02:39:44 -04:00
shared Fix incorrect server error content in RunnersList (#24118) 2023-04-14 11:34:10 +08:00
user Fix unclear "Owner" concept (#24233) 2023-04-20 19:33:30 +02:00
auth_windows.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
auth.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
base.go Improve Wiki TOC (#24137) 2023-04-17 15:05:19 -04:00
goget.go refactor some functions to support ctx as first parameter (#21878) 2022-12-03 10:48:26 +08:00
home.go Refactor cookie (#24107) 2023-04-13 15:45:33 -04:00
metrics.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
nodeinfo.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
swagger_json.go Group template helper functions, remove Printf, improve template error messages (#23982) 2023-04-08 21:15:22 +08:00
web.go Refactor web route (#24080) 2023-04-20 14:49:06 -04:00
webfinger.go Use User.ID instead of User.Name in ActivityPub API for Person IRI (#23823) 2023-04-04 10:08:23 +08:00