This commit is contained in:
HeshamTB 2023-09-21 17:10:06 +03:00
parent 0cc4a8a92f
commit fb405dc55c

15
main.go
View File

@ -183,21 +183,12 @@ func handleDownload(w http.ResponseWriter, r *http.Request) {
} }
ctx.DownloadURL = downloadURL ctx.DownloadURL = downloadURL
w.Header().Add( ctx.DownloadURL = fmt.Sprintf("/download-direct?URL=%s&filename=%s",
"Hx-Redirect",
fmt.Sprintf("/download-direct?URL=%s&filename=%s",
url.QueryEscape(ctx.DownloadURL), url.QueryEscape(ctx.DownloadURL),
url.QueryEscape(filename)), url.QueryEscape(filename),
) )
err = templates.ExecuteTemplate(w,"download-result.html", ctx) w.Header().Add("Hx-Redirect", ctx.DownloadURL)
if err != nil {
log.Println(err.Error())
ctx.StatusCode = 500
ctx.Err = &err
err = templates.ExecuteTemplate(w,"download-result.html", ctx)
return
}
} }
func handleDirectDownload(w http.ResponseWriter, r *http.Request) { func handleDirectDownload(w http.ResponseWriter, r *http.Request) {