test_helpers.go 433 B

123456789101112131415161718
  1. // Copyright 2017 Manu Martinez-Almeida. All rights reserved.
  2. // Use of this source code is governed by a MIT style
  3. // license that can be found in the LICENSE file.
  4. package gin
  5. import (
  6. "net/http"
  7. )
  8. // CreateTestContext returns a fresh engine and context for testing purposes
  9. func CreateTestContext(w http.ResponseWriter) (c *Context, r *Engine) {
  10. r = New()
  11. c = r.allocateContext()
  12. c.reset()
  13. c.writermem.reset(w)
  14. return
  15. }