mirror of
https://github.com/go-gitea/gitea.git
synced 2026-11-26 15:30:59 +00:00
Refactor request context (#32956)
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.
This commit is contained in:
1 parent
781c6df40f
commit
6d5aa9218e
34 files changed
+379
-422
No files matched your search
@@ -10,6 +10,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/modules/htmlutil"
|
||||
"code.gitea.io/gitea/modules/reqctx"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/web/middleware"
|
||||
|
||||
@@ -29,12 +30,12 @@ func Bind[T any](_ T) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// SetForm set the form object
|
||||
func SetForm(dataStore middleware.ContextDataStore, obj any) {
|
||||
func SetForm(dataStore reqctx.ContextDataProvider, obj any) {
|
||||
dataStore.GetData()["__form"] = obj
|
||||
}
|
||||
|
||||
// GetForm returns the validate form information
|
||||
func GetForm(dataStore middleware.ContextDataStore) any {
|
||||
func GetForm(dataStore reqctx.RequestDataStore) any {
|
||||
return dataStore.GetData()["__form"]
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user