-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Refactor HTTP request context #17979
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
CI failure is not related. Other passed PRs also have such failure: |
Codecov Report
@@ Coverage Diff @@
## main #17979 +/- ##
=======================================
Coverage ? 45.28%
=======================================
Files ? 820
Lines ? 90930
Branches ? 0
=======================================
Hits ? 41174
Misses ? 43195
Partials ? 6561
Continue to review full report at Codecov.
|
Background
I was working on some new enhancements, while I found the modules/context/context.go is quite messy, so I think it's better to refactor first before other works.
Major Changes
HTMLString(name string, data interface{})=>RenderToString(name base.TplName, data map[string]interface{}), the first paramter is aTplName, and the oldHTMLStringnaming conflicts with other function names likeHTML/PlainTextTmplLoadTimesis reworked. The oldTmplLoadTimesin oldHTMLStringhas no effects because the render doesn't usectx.DataNotFound(title string, err error)andServerError(title string, err error)related functions are refactored, because thetitleis not title, it only appears in log.PlainText(string)andPlainTextBytes([]byte)to replace oldPlainText([]bytes)andHandleText(string)SignedUserNametype contextKeyType struct{}; var contextKey interface{} = contextKeyType{}to replacevar contextKey interface{} = "default_context"ctx.RespHeader()to replacectx.Header(), becausectx.Header()is not clear whether it is for request or response.