Use server context

This commit is contained in:
Dane Everitt 2021-01-26 19:36:35 -08:00
parent 4411493006
commit 13541524c3
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53

View File

@ -1,7 +1,6 @@
package router
import (
"context"
"net/http"
"os"
"strings"
@ -117,7 +116,10 @@ func postServerRestoreBackup(c *gin.Context) {
// TODO: this will hang if there is an issue. We can't use c.Request.Context() (or really any)
// since it will be canceled when the request is closed which happens quickly since we push
// this into the background.
req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, data.DownloadUrl, nil)
//
// For now I'm just using the server context so at least the request is canceled if
// the server gets deleted.
req, err := http.NewRequestWithContext(s.Context(), http.MethodGet, data.DownloadUrl, nil)
if err != nil {
middleware.CaptureAndAbort(c, err)
return