From fb405dc55cc66f2af69b51d175001563b712eeca Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Thu, 21 Sep 2023 17:10:06 +0300 Subject: [PATCH] cleanup --- main.go | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/main.go b/main.go index 42196b3..37d4fd4 100644 --- a/main.go +++ b/main.go @@ -183,21 +183,12 @@ func handleDownload(w http.ResponseWriter, r *http.Request) { } ctx.DownloadURL = downloadURL - w.Header().Add( - "Hx-Redirect", - fmt.Sprintf("/download-direct?URL=%s&filename=%s", + ctx.DownloadURL = fmt.Sprintf("/download-direct?URL=%s&filename=%s", url.QueryEscape(ctx.DownloadURL), - url.QueryEscape(filename)), + url.QueryEscape(filename), ) - err = templates.ExecuteTemplate(w,"download-result.html", ctx) - if err != nil { - log.Println(err.Error()) - ctx.StatusCode = 500 - ctx.Err = &err - err = templates.ExecuteTemplate(w,"download-result.html", ctx) - return - } + w.Header().Add("Hx-Redirect", ctx.DownloadURL) } func handleDirectDownload(w http.ResponseWriter, r *http.Request) {