CreateTestContextOnly returns a fresh Context associated with the provided Engine `r`. This is useful for tests that operate on an existing, possibly pre-configured, Gin engine instance and need a new context for it. The ResponseWriter `w` is used to initialize the context's writer. The context is a
(w http.ResponseWriter, r *Engine)
| 28 | // The ResponseWriter `w` is used to initialize the context's writer. |
| 29 | // The context is allocated with the `maxParams` setting from the provided engine. |
| 30 | func CreateTestContextOnly(w http.ResponseWriter, r *Engine) (c *Context) { |
| 31 | c = r.allocateContext(r.maxParams) |
| 32 | c.reset() |
| 33 | c.writermem.reset(w) |
| 34 | return |
| 35 | } |
| 36 | |
| 37 | // waitForServerReady waits for a server to be ready by making HTTP requests |
| 38 | // with exponential backoff. This is more reliable than time.Sleep() for testing. |