Added HandleContext to re-enter soft-rewritten Requests. (#709)
This commit is contained in:
parent
049da60f51
commit
2ae8a25fc9
9
gin.go
9
gin.go
@ -273,6 +273,15 @@ func (engine *Engine) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
|||||||
engine.pool.Put(c)
|
engine.pool.Put(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Re-enter a context that has been rewritten.
|
||||||
|
// This can be done by setting c.Request.Path to your new target.
|
||||||
|
// Disclaimer: You can loop yourself to death with this, use wisely.
|
||||||
|
func (engine *Engine) HandleContext(c *Context) {
|
||||||
|
c.reset()
|
||||||
|
engine.handleHTTPRequest(c)
|
||||||
|
engine.pool.Put(c)
|
||||||
|
}
|
||||||
|
|
||||||
func (engine *Engine) handleHTTPRequest(context *Context) {
|
func (engine *Engine) handleHTTPRequest(context *Context) {
|
||||||
httpMethod := context.Request.Method
|
httpMethod := context.Request.Method
|
||||||
path := context.Request.URL.Path
|
path := context.Request.URL.Path
|
||||||
|
Loading…
Reference in New Issue
Block a user