(cherry picked from commit 75701695d8)
Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
This commit is contained in:
co-authored by
Emil Tullstedt
parent
68882a861a
commit
4d00a510d1
+7
-1
@@ -144,8 +144,14 @@ func mwFromHandler(handler Handler) Middleware {
|
||||
}
|
||||
|
||||
func (m *Macaron) createContext(rw http.ResponseWriter, req *http.Request) *Context {
|
||||
// NOTE: we have to explicitly copy the middleware chain here to avoid
|
||||
// passing a shared slice to the *Context, which leads to racy behavior in
|
||||
// case of later appends
|
||||
mws := make([]Middleware, len(m.mws))
|
||||
copy(mws, m.mws)
|
||||
|
||||
c := &Context{
|
||||
mws: m.mws,
|
||||
mws: mws,
|
||||
Resp: NewResponseWriter(req.Method, rw),
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user