mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
pkg/web: avoid shared middleware slice (#58458)
This commit is contained in:
parent
2e6761b4e4
commit
75701695d8
@ -144,8 +144,14 @@ func mwFromHandler(handler Handler) Middleware {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Macaron) createContext(rw http.ResponseWriter, req *http.Request) *Context {
|
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{
|
c := &Context{
|
||||||
mws: m.mws,
|
mws: mws,
|
||||||
Resp: NewResponseWriter(req.Method, rw),
|
Resp: NewResponseWriter(req.Method, rw),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user