mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-26 11:01:07 +01:00
refactor(http): performance improvement
- Introduced a sync.Pool for ResponseRecorder to optimize memory usage. - Updated ServeHTTP method to utilize the new GetResponseRecorder and PutResponseRecorder functions. - Adjusted NewResponseRecorder to leverage the pooling mechanism.
This commit is contained in:
@@ -97,9 +97,12 @@ func (ep *Entrypoint) FindRoute(s string) types.HTTPRoute {
|
||||
|
||||
func (ep *Entrypoint) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
if ep.accessLogger != nil {
|
||||
rec := accesslog.NewResponseRecorder(w)
|
||||
rec := accesslog.GetResponseRecorder(w)
|
||||
w = rec
|
||||
defer ep.accessLogger.Log(r, rec.Response())
|
||||
defer func() {
|
||||
ep.accessLogger.Log(r, rec.Response())
|
||||
accesslog.PutResponseRecorder(rec)
|
||||
}()
|
||||
}
|
||||
|
||||
route := ep.findRouteFunc(r.Host)
|
||||
|
||||
Reference in New Issue
Block a user