mirror of
https://github.com/nielsAD/autoindex.git
synced 2026-05-07 00:57:54 +02:00
Use req.Context() to cancel processing requests early
This commit is contained in:
4
fs.go
4
fs.go
@@ -320,7 +320,7 @@ func (fs *CachedFS) serveCache(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), fs.Timeout)
|
||||
ctx, cancel := context.WithTimeout(r.Context(), fs.Timeout)
|
||||
defer cancel()
|
||||
|
||||
p := cleanPath(r.URL.Path)
|
||||
@@ -465,7 +465,7 @@ func (fs *CachedFS) Sitemap(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), fs.Timeout)
|
||||
ctx, cancel := context.WithTimeout(r.Context(), fs.Timeout)
|
||||
defer cancel()
|
||||
|
||||
var rows *sql.Rows
|
||||
|
||||
Reference in New Issue
Block a user