fix: download link was incorrect. Added hint for saving file

This commit is contained in:
HeshamTB 2023-09-11 23:42:58 +03:00
parent 84c85c98fe
commit d047788835
2 changed files with 6 additions and 1 deletions

View File

@ -88,6 +88,7 @@ type Context struct {
StatusCode int StatusCode int
Err *error Err *error
IsTLS bool IsTLS bool
DownloadURL string
} }
func NewContext(r *http.Request) *Context { func NewContext(r *http.Request) *Context {
@ -173,6 +174,7 @@ func main() {
downloadURL := string(body) downloadURL := string(body)
log.Println("URL from convx", downloadURL) log.Println("URL from convx", downloadURL)
ctx.DownloadURL = downloadURL
err = templates.ExecuteTemplate(w,"download-result.html", ctx) err = templates.ExecuteTemplate(w,"download-result.html", ctx)
if err != nil { if err != nil {
log.Println(err.Error()) log.Println(err.Error())

View File

@ -1,6 +1,9 @@
<div id="get-btn"> <div id="get-btn">
{{ if eq .StatusCode 200 }} {{ if eq .StatusCode 200 }}
<a href="{{ . }}" rel="" download target="_blank">Download</a> <a href="{{ .DownloadURL }}" rel="noopener" download target="_blank">
Download
</a>
<small>Right click and Click "Save link as"</small>
{{ else }} {{ else }}
<button>Try Again <button>Try Again
<!-- <a class="htmx-indicator" href="#" aria-busy="true"></a> --> <!-- <a class="htmx-indicator" href="#" aria-busy="true"></a> -->