...

Source file src/github.com/gin-gonic/gin/test_helpers.go

Documentation: github.com/gin-gonic/gin

     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  
     5  package gin
     6  
     7  import "net/http"
     8  
     9  // CreateTestContext returns a fresh engine and context for testing purposes
    10  func CreateTestContext(w http.ResponseWriter) (c *Context, r *Engine) {
    11  	r = New()
    12  	c = r.allocateContext(0)
    13  	c.reset()
    14  	c.writermem.reset(w)
    15  	return
    16  }
    17  
    18  // CreateTestContextOnly returns a fresh context base on the engine for testing purposes
    19  func CreateTestContextOnly(w http.ResponseWriter, r *Engine) (c *Context) {
    20  	c = r.allocateContext(r.maxParams)
    21  	c.reset()
    22  	c.writermem.reset(w)
    23  	return
    24  }
    25  

View as plain text