Commit Graph

12 Commits (dc7ddaee2aca7c3c1652a5b287c3047612c1c655)

Author SHA1 Message Date
wxiaoguang b15d01b0ce
Prepare for support performance trace ()
For 
wxiaoguang 2a828e2798
Clarify path param naming ()
In history (from some legacy frameworks), both `:name` and `name` are
supported as path path name, `:name` is an alias to `name`.

To make code consistent, now we should only use `name` but not `:name`.

Also added panic check in related functions to make sure the name won't
be abused in case some downstreams still use them.
wxiaoguang 6d5aa9218e
Refactor request context ()
Introduce RequestContext: is a short-lived context that is used to store
request-specific data.

RequestContext could be used to clean form tmp files, close context git
repo, and do some tracing in the future.

Then a lot of legacy code could be removed or improved. For example:
most `ctx.Repo.GitRepo.Close()` could be removed because the git repo
could be closed when the request is done.
wxiaoguang 0aedb03996
Fix LFS route mock, realm, middleware names ()
1. move "internal-lfs" route mock to "common-lfs"
2. fine tune tests
3. fix "realm" strings, according to RFC:
https://datatracker.ietf.org/doc/html/rfc2617:
    * realm       = "realm" "=" realm-value
    * realm-value = quoted-string
4. clarify some names of the middlewares, rename `ignXxx` to `optXxx` to
match `reqXxx`, and rename ambiguous `requireSignIn` to `reqGitSignIn`
wxiaoguang 43c7a2e7b1
Refactor names ()
This PR only does "renaming":

* `Route` should be `Router` (and chi router is also called "router")
* `Params` should be `PathParam` (to distingush it from URL query param, and to match `FormString`)
* Use lower case for private functions to avoid exposing or abusing
wxiaoguang d32648b204
Refactor route path normalization ()
Refactor route path normalization and decouple it from the chi router.
Fix the TODO, fix the legacy strange path behavior.
wxiaoguang 7424f27cf3
Check if reverse proxy is correctly configured ()
Follow 
Follow 

---------

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Giteabot <teabot@gitea.io>
wxiaoguang 67c1a07285
Refactor AppURL usage ()
Fix 
Fix 

---------

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
wxiaoguang 53b55223d1
Ignore useless error message "broken pipe" ()
Fix 
wxiaoguang c72e1a7abb
Use strict protocol check when redirect ()
6543 274c0aea2e
Let ctx.FormOptionalBool() return optional.Option[bool] ()
just some refactoring bits towards replacing **util.OptionalBool** with
**optional.Option[bool]**
Lunny Xiao 29f149bd9f
Move context from modules to services ()
Since `modules/context` has to depend on `models` and many other
packages, it should be moved from `modules/context` to
`services/context` according to design principles. There is no logic
code change on this PR, only move packages.

- Move `code.gitea.io/gitea/modules/context` to
`code.gitea.io/gitea/services/context`
- Move `code.gitea.io/gitea/modules/contexttest` to
`code.gitea.io/gitea/services/contexttest` because of depending on
context
- Move `code.gitea.io/gitea/modules/upload` to
`code.gitea.io/gitea/services/context/upload` because of depending on
context