mirror of
https://github.com/kataras/iris.git
synced 2025-12-22 04:17:03 +00:00
add Context#ResetRequest and core/handlerconv.FromStdWithNext updates the request for any incoming request changes - https://github.com/kataras/iris/issues/1180
Former-commit-id: 764bf26bcaa3b7bdae0a2bdbf3bf2b6f8c5c546e
This commit is contained in:
@@ -114,6 +114,18 @@ type Context interface {
|
||||
|
||||
// Request returns the original *http.Request, as expected.
|
||||
Request() *http.Request
|
||||
// ResetRequest sets the Context's Request,
|
||||
// It is useful to store the new request created by a std *http.Request#WithContext() into Iris' Context.
|
||||
// Use `ResetRequest` when for some reason you want to make a full
|
||||
// override of the *http.Request.
|
||||
// Note that: when you just want to change one of each fields you can use the Request() which returns a pointer to Request,
|
||||
// so the changes will have affect without a full override.
|
||||
// Usage: you use a native http handler which uses the standard "context" package
|
||||
// to get values instead of the Iris' Context#Values():
|
||||
// r := c.Request()
|
||||
// stdCtx := context.WithValue(r.Context(), key, val)
|
||||
// ctx.ResetRequest(r.WithContext(stdCtx)).
|
||||
ResetRequest(r *http.Request)
|
||||
|
||||
// SetCurrentRouteName sets the route's name internally,
|
||||
// in order to be able to find the correct current "read-only" Route when
|
||||
@@ -1068,6 +1080,21 @@ func (ctx *context) Request() *http.Request {
|
||||
return ctx.request
|
||||
}
|
||||
|
||||
// ResetRequest sets the Context's Request,
|
||||
// It is useful to store the new request created by a std *http.Request#WithContext() into Iris' Context.
|
||||
// Use `ResetRequest` when for some reason you want to make a full
|
||||
// override of the *http.Request.
|
||||
// Note that: when you just want to change one of each fields you can use the Request() which returns a pointer to Request,
|
||||
// so the changes will have affect without a full override.
|
||||
// Usage: you use a native http handler which uses the standard "context" package
|
||||
// to get values instead of the Iris' Context#Values():
|
||||
// r := c.Request()
|
||||
// stdCtx := context.WithValue(r.Context(), key, val)
|
||||
// ctx.ResetRequest(r.WithContext(stdCtx)).
|
||||
func (ctx *context) ResetRequest(r *http.Request) {
|
||||
ctx.request = r
|
||||
}
|
||||
|
||||
// SetCurrentRouteName sets the route's name internally,
|
||||
// in order to be able to find the correct current "read-only" Route when
|
||||
// end-developer calls the `GetCurrentRoute()` function.
|
||||
|
||||
Reference in New Issue
Block a user