mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-17 22:32:26 +08:00
Fix for issue #2460
This commit is contained in:
parent
b94d23d1b4
commit
8321affbca
@ -102,6 +102,7 @@ func (c *Context) reset() {
|
||||
// Copy returns a copy of the current context that can be safely used outside the request's scope.
|
||||
// This has to be used when the context has to be passed to a goroutine.
|
||||
func (c *Context) Copy() *Context {
|
||||
c.mu.Lock()
|
||||
cp := Context{
|
||||
writermem: c.writermem,
|
||||
Request: c.Request,
|
||||
@ -119,6 +120,7 @@ func (c *Context) Copy() *Context {
|
||||
paramCopy := make([]Param, len(cp.Params))
|
||||
copy(paramCopy, cp.Params)
|
||||
cp.Params = paramCopy
|
||||
c.mu.Unlock()
|
||||
return &cp
|
||||
}
|
||||
|
||||
@ -957,7 +959,7 @@ func (c *Context) File(filepath string) {
|
||||
http.ServeFile(c.Writer, c.Request, filepath)
|
||||
}
|
||||
|
||||
// FileFromFS writes the specified file from http.FileSytem into the body stream in an efficient way.
|
||||
// FileFromFS writes the specified file from http.FileSystem into the body stream in an efficient way.
|
||||
func (c *Context) FileFromFS(filepath string, fs http.FileSystem) {
|
||||
defer func(old string) {
|
||||
c.Request.URL.Path = old
|
||||
|
Loading…
x
Reference in New Issue
Block a user