labstack / echo

High performance, minimalist Go web framework
https://echo.labstack.com
MIT License
29.94k stars 2.23k forks source link

using `echo.AcquireContext` #2698

Open poteto0 opened 2 weeks ago

poteto0 commented 2 weeks ago

CHANGE

use method, echo.AcqurireContext which defined.

-func (e *Echo) AcquireContext() Context {
-   return e.pool.Get().(Context)
+func (e *Echo) AcquireContext() *context {
+     return e.pool.Get().(*context)
}

func (e *Echo) ServeHTTP(w http.ResponseWriter, r *http.Request) {
    // Acquire context
-       c := e.pool.Get().(*context)
+   c := e.AcquireContext()
        ....
        // Release context
-   e.pool.Put(c)
+   e.ReleaseContext(c)
}