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.
b9a97ccd0e
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 | 1 year ago | |
activitypub | 1 year ago | |
analyze | 2 years ago | |
assetfs | 1 year ago | |
auth | 1 year ago | |
avatar | 1 year ago | |
base | 1 year ago | |
cache | 1 year ago | |
charset | 1 year ago | |
container | 2 years ago | |
context | 1 year ago | |
csv | 1 year ago | |
doctor | 1 year ago | |
emoji | 2 years ago | |
eventsource | 2 years ago | |
generate | 2 years ago | |
git | 1 year ago | |
gitgraph | 1 year ago | |
graceful | 1 year ago | |
hcaptcha | 1 year ago | |
highlight | 1 year ago | |
hostmatcher | 2 years ago | |
html | 2 years ago | |
httpcache | 1 year ago | |
httplib | 1 year ago | |
indexer | 1 year ago | |
issue/template | 2 years ago | |
json | 2 years ago | |
label | 1 year ago | |
lfs | 1 year ago | |
log | 1 year ago | |
markup | 1 year ago | |
mcaptcha | 2 years ago | |
metrics | 1 year ago | |
migration | 1 year ago | |
mirror | 2 years ago | |
nosql | 1 year ago | |
notification | 1 year ago | |
options | 1 year ago | |
packages | 1 year ago | |
paginator | 2 years ago | |
pprof | 2 years ago | |
private | 1 year ago | |
process | 1 year ago | |
proxy | 1 year ago | |
proxyprotocol | 2 years ago | |
public | 1 year ago | |
queue | 1 year ago | |
recaptcha | 2 years ago | |
references | 1 year ago | |
regexplru | 2 years ago | |
repository | 1 year ago | |
secret | 1 year ago | |
session | 1 year ago | |
setting | 1 year ago | |
sitemap | 2 years ago | |
ssh | 2 years ago | |
storage | 1 year ago | |
structs | 1 year ago | |
svg | 1 year ago | |
sync | 2 years ago | |
system | 2 years ago | |
templates | 1 year ago | |
test | 1 year ago | |
timeutil | 1 year ago | |
translation | 1 year ago | |
turnstile | 1 year ago | |
typesniffer | 1 year ago | |
updatechecker | 2 years ago | |
upload | 2 years ago | |
uri | 2 years ago | |
user | 2 years ago | |
util | 1 year ago | |
validation | 1 year ago | |
web | 1 year ago | |
webhook | 2 years ago |