You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
forgejo/modules
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
1 year ago
..
actions Support triggering workflows by wiki related events (#24119) 1 year ago
activitypub Add Chef package registry (#22554) 1 year ago
analyze Implement FSFE REUSE for golang files (#21840) 2 years ago
assetfs Use a general approach to access custom/static/builtin assets (#24022) 1 year ago
auth Use a general approach to access custom/static/builtin assets (#24022) 1 year ago
avatar Use minio/sha256-simd for accelerated SHA256 (#23052) 1 year ago
base Use a general Eval function for expressions in templates. (#23927) 1 year ago
cache Update redis library to support redis v7 (#24114) 1 year ago
charset Refactor locale number (#24134) 1 year ago
container Implement FSFE REUSE for golang files (#21840) 2 years ago
context Make HTML template functions support context (#24056) 1 year ago
csv Refactor locale number (#24134) 1 year ago
doctor Use a general approach to access custom/static/builtin assets (#24022) 1 year ago
emoji Fix unstable emoji sort (#22346) 2 years ago
eventsource Move `convert` package to services (#22264) 2 years ago
generate Implement FSFE REUSE for golang files (#21840) 2 years ago
git Make wiki title supports dashes and improve wiki name related features (#24143) 1 year ago
gitgraph Add context cache as a request level cache (#22294) 1 year ago
graceful Remove most path-based golangci exclusions (#24214) 1 year ago
hcaptcha Consume hcaptcha and pwn deps (#22610) 1 year ago
highlight test_env: hardcode major go version in use (#23464) 1 year ago
hostmatcher Implement FSFE REUSE for golang files (#21840) 2 years ago
html Implement FSFE REUSE for golang files (#21840) 2 years ago
httpcache Set `X-Gitea-Debug` header once (#23361) 1 year ago
httplib Refactor internal API for git commands, use meaningful messages instead of "Internal Server Error" (#23687) 1 year ago
indexer Allow adding new files to an empty repo (#24164) 1 year ago
issue/template Allow issue templates to not render title (#22589) 1 year ago
json Update gitea-vet to check FSFE REUSE (#22004) 2 years ago
label Make label templates have consistent behavior and priority (#23749) 1 year ago
lfs Make minio package support legacy MD5 checksum (#23768) 1 year ago
log Remove most path-based golangci exclusions (#24214) 1 year ago
markup Improve Wiki TOC (#24137) 1 year ago
mcaptcha Implement FSFE REUSE for golang files (#21840) 2 years ago
metrics include build info in Prometheus metrics (#22819) 1 year ago
migration Scoped labels (#22585) 1 year ago
mirror Implement FSFE REUSE for golang files (#21840) 2 years ago
nosql Update redis library to support redis v7 (#24114) 1 year ago
notification Implement actions (#21937) 1 year ago
options Use a general approach to access custom/static/builtin assets (#24022) 1 year ago
packages Display image size for multiarch container images (#23821) 1 year ago
paginator Update gitea-vet to check FSFE REUSE (#22004) 2 years ago
pprof Implement FSFE REUSE for golang files (#21840) 2 years ago
private Fix incorrect internal response type (#24173) 1 year ago
process Improve trace logging for pulls and processes (#22633) 1 year ago
proxy Use proxy for pull mirror (#22771) 1 year ago
proxyprotocol Implement FSFE REUSE for golang files (#21840) 2 years ago
public Use a general approach to access custom/static/builtin assets (#24022) 1 year ago
queue Update redis library to support redis v7 (#24114) 1 year ago
recaptcha Implement FSFE REUSE for golang files (#21840) 2 years ago
references Use correct captured group range when parsing cross-reference (#22672) 1 year ago
regexplru Implement FSFE REUSE for golang files (#21840) 2 years ago
repository Use a general approach to access custom/static/builtin assets (#24022) 1 year ago
secret Use minio/sha256-simd for accelerated SHA256 (#23052) 1 year ago
session Update redis library to support redis v7 (#24114) 1 year ago
setting Fix incorrect CORS default values (#24206) 1 year ago
sitemap Fix sitemap (#22272) 2 years ago
ssh Implement FSFE REUSE for golang files (#21840) 2 years ago
storage Make minio package support legacy MD5 checksum (#23768) 1 year ago
structs Fix Org edit page bugs: renaming detection, maxlength (#24161) 1 year ago
svg Use a general approach to access custom/static/builtin assets (#24022) 1 year ago
sync Implement FSFE REUSE for golang files (#21840) 2 years ago
system Implement FSFE REUSE for golang files (#21840) 2 years ago
templates Make HTML template functions support context (#24056) 1 year ago
test Make HTML template functions support context (#24056) 1 year ago
timeutil Remove untranslatable `on_date` key (#24106) 1 year ago
translation Refactor locale number (#24134) 1 year ago
turnstile Add new captcha: cloudflare turnstile (#22369) 1 year ago
typesniffer Do not recognize text files as audio (#23355) 1 year ago
updatechecker Implement FSFE REUSE for golang files (#21840) 2 years ago
upload Implement FSFE REUSE for golang files (#21840) 2 years ago
uri Implement FSFE REUSE for golang files (#21840) 2 years ago
user Implement FSFE REUSE for golang files (#21840) 2 years ago
util Use a general approach to access custom/static/builtin assets (#24022) 1 year ago
validation Map OIDC groups to Orgs/Teams (#21441) 1 year ago
web Refactor web route (#24080) 1 year ago
webhook Restructure `webhook` module (#22256) 2 years ago