gitea/modules
wxiaoguang b9a97ccd0e
Refactor web route ()
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
..
actions Support triggering workflows by wiki related events () 2023-04-17 13:49:47 -04:00
activitypub Add Chef package registry () 2023-02-06 09:49:21 +08:00
analyze Implement FSFE REUSE for golang files () 2022-11-27 18:20:29 +00:00
assetfs Use a general approach to access custom/static/builtin assets () 2023-04-12 18:16:45 +08:00
auth Use a general approach to access custom/static/builtin assets () 2023-04-12 18:16:45 +08:00
avatar Use minio/sha256-simd for accelerated SHA256 () 2023-02-22 14:21:46 -05:00
base Use a general Eval function for expressions in templates. () 2023-04-07 21:25:49 +08:00
cache Update redis library to support redis v7 () 2023-04-13 18:41:04 -04:00
charset Refactor locale number () 2023-04-17 11:37:23 +08:00
container Implement FSFE REUSE for golang files () 2022-11-27 18:20:29 +00:00
context Make HTML template functions support context () 2023-04-20 04:08:58 -04:00
csv Refactor locale number () 2023-04-17 11:37:23 +08:00
doctor Use a general approach to access custom/static/builtin assets () 2023-04-12 18:16:45 +08:00
emoji Fix unstable emoji sort () 2023-01-05 13:58:51 +02:00
eventsource Move `convert` package to services () 2022-12-29 10:57:15 +08:00
generate Implement FSFE REUSE for golang files () 2022-11-27 18:20:29 +00:00
git Make wiki title supports dashes and improve wiki name related features () 2023-04-19 13:50:10 -04:00
gitgraph Add context cache as a request level cache () 2023-02-15 21:37:34 +08:00
graceful Remove most path-based golangci exclusions () 2023-04-19 22:08:01 -04:00
hcaptcha Consume hcaptcha and pwn deps () 2023-01-29 09:49:51 -06:00
highlight test_env: hardcode major go version in use () 2023-03-14 16:09:01 -04:00
hostmatcher Implement FSFE REUSE for golang files () 2022-11-27 18:20:29 +00:00
html Implement FSFE REUSE for golang files () 2022-11-27 18:20:29 +00:00
httpcache Set `X-Gitea-Debug` header once () 2023-03-08 15:40:04 -05:00
httplib Refactor internal API for git commands, use meaningful messages instead of "Internal Server Error" () 2023-03-29 14:32:26 +08:00
indexer Allow adding new files to an empty repo () 2023-04-19 21:40:42 +08:00
issue/template Allow issue templates to not render title () 2023-01-26 22:45:49 -06:00
json Update gitea-vet to check FSFE REUSE () 2022-12-02 22:14:57 +08:00
label Make label templates have consistent behavior and priority () 2023-04-10 16:44:02 +08:00
lfs Make minio package support legacy MD5 checksum () 2023-03-28 11:10:24 -04:00
log Remove most path-based golangci exclusions () 2023-04-19 22:08:01 -04:00
markup Improve Wiki TOC () 2023-04-17 15:05:19 -04:00
mcaptcha Implement FSFE REUSE for golang files () 2022-11-27 18:20:29 +00:00
metrics include build info in Prometheus metrics () 2023-02-08 19:54:01 +02:00
migration Scoped labels () 2023-02-18 21:17:39 +02:00
mirror Implement FSFE REUSE for golang files () 2022-11-27 18:20:29 +00:00
nosql Update redis library to support redis v7 () 2023-04-13 18:41:04 -04:00
notification Implement actions () 2023-01-31 09:45:19 +08:00
options Use a general approach to access custom/static/builtin assets () 2023-04-12 18:16:45 +08:00
packages Display image size for multiarch container images () 2023-04-02 17:53:37 +08:00
paginator Update gitea-vet to check FSFE REUSE () 2022-12-02 22:14:57 +08:00
pprof Implement FSFE REUSE for golang files () 2022-11-27 18:20:29 +00:00
private Fix incorrect internal response type () 2023-04-17 23:10:40 -04:00
process Improve trace logging for pulls and processes () 2023-02-03 18:11:48 -05:00
proxy Use proxy for pull mirror () 2023-02-11 08:39:50 +08:00
proxyprotocol Implement FSFE REUSE for golang files () 2022-11-27 18:20:29 +00:00
public Use a general approach to access custom/static/builtin assets () 2023-04-12 18:16:45 +08:00
queue Update redis library to support redis v7 () 2023-04-13 18:41:04 -04:00
recaptcha Implement FSFE REUSE for golang files () 2022-11-27 18:20:29 +00:00
references Use correct captured group range when parsing cross-reference () 2023-01-31 10:08:05 +01:00
regexplru Implement FSFE REUSE for golang files () 2022-11-27 18:20:29 +00:00
repository Use a general approach to access custom/static/builtin assets () 2023-04-12 18:16:45 +08:00
secret Use minio/sha256-simd for accelerated SHA256 () 2023-02-22 14:21:46 -05:00
session Update redis library to support redis v7 () 2023-04-13 18:41:04 -04:00
setting Fix incorrect CORS default values () 2023-04-19 15:30:10 -04:00
sitemap Fix sitemap () 2022-12-30 23:31:00 +08:00
ssh Implement FSFE REUSE for golang files () 2022-11-27 18:20:29 +00:00
storage Make minio package support legacy MD5 checksum () 2023-03-28 11:10:24 -04:00
structs Fix Org edit page bugs: renaming detection, maxlength () 2023-04-17 11:35:57 -04:00
svg Use a general approach to access custom/static/builtin assets () 2023-04-12 18:16:45 +08:00
sync Implement FSFE REUSE for golang files () 2022-11-27 18:20:29 +00:00
system Implement FSFE REUSE for golang files () 2022-11-27 18:20:29 +00:00
templates Make HTML template functions support context () 2023-04-20 04:08:58 -04:00
test Make HTML template functions support context () 2023-04-20 04:08:58 -04:00
timeutil Remove untranslatable `on_date` key () 2023-04-15 13:01:54 +02:00
translation Refactor locale number () 2023-04-17 11:37:23 +08:00
turnstile Add new captcha: cloudflare turnstile () 2023-02-05 15:29:03 +08:00
typesniffer Do not recognize text files as audio () 2023-03-07 22:40:41 -05:00
updatechecker Implement FSFE REUSE for golang files () 2022-11-27 18:20:29 +00:00
upload Implement FSFE REUSE for golang files () 2022-11-27 18:20:29 +00:00
uri Implement FSFE REUSE for golang files () 2022-11-27 18:20:29 +00:00
user Implement FSFE REUSE for golang files () 2022-11-27 18:20:29 +00:00
util Use a general approach to access custom/static/builtin assets () 2023-04-12 18:16:45 +08:00
validation Map OIDC groups to Orgs/Teams () 2023-02-08 14:44:42 +08:00
web Refactor web route () 2023-04-20 14:49:06 -04:00
webhook Restructure `webhook` module () 2023-01-01 23:23:15 +08:00