cache headers, redirect to format=html by default
This commit is contained in:
@@ -134,7 +134,11 @@ func logic() error {
|
|||||||
debugHTML(w, r, prefix, qrch)
|
debugHTML(w, r, prefix, qrch)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: add cache control headers
|
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
|
||||||
|
// […] this alone is the only directive you need in preventing cached
|
||||||
|
// responses on modern browsers.
|
||||||
|
w.Header().Add("Cache-Control", "no-store")
|
||||||
|
|
||||||
if _, err := io.Copy(w, bytes.NewReader(b)); err != nil {
|
if _, err := io.Copy(w, bytes.NewReader(b)); err != nil {
|
||||||
log.Printf("%s %s", prefix, err)
|
log.Printf("%s %s", prefix, err)
|
||||||
return
|
return
|
||||||
@@ -146,13 +150,7 @@ func logic() error {
|
|||||||
http.Error(w, "not found", http.StatusNotFound)
|
http.Error(w, "not found", http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.Header().Add("Content-Type", "text/html; charset=utf-8")
|
http.Redirect(w, r, "/qr?format=html", http.StatusFound)
|
||||||
// TODO: add explanation for how to construct a URL
|
|
||||||
// e.g. for usage in filemaker web view
|
|
||||||
fmt.Fprintf(w, "<ul>")
|
|
||||||
fmt.Fprintf(w, `<li>PNG referenz: <a href="/qr.png">qr.png</a>`+"\n")
|
|
||||||
fmt.Fprintf(w, `<li>SVG scalable: <a href="/qr.svg">qr.svg</a>`+"\n")
|
|
||||||
fmt.Fprintf(w, `<li>debug: <a href="/qr.html">qr.html</a>, or <a href="/qr.txt">qr.txt</a>`+"\n")
|
|
||||||
})
|
})
|
||||||
log.Printf("QR Bill generation URL: http://%s/qr?format=html", *listen)
|
log.Printf("QR Bill generation URL: http://%s/qr?format=html", *listen)
|
||||||
return http.ListenAndServe(*listen, nil)
|
return http.ListenAndServe(*listen, nil)
|
||||||
|
|||||||
2
go.mod
2
go.mod
@@ -6,6 +6,6 @@ require (
|
|||||||
github.com/aaronarduino/goqrsvg v0.0.0-20170617203649-603647895681
|
github.com/aaronarduino/goqrsvg v0.0.0-20170617203649-603647895681
|
||||||
github.com/ajstarks/svgo v0.0.0-20200320125537-f189e35d30ca
|
github.com/ajstarks/svgo v0.0.0-20200320125537-f189e35d30ca
|
||||||
github.com/boombuler/barcode v1.0.0
|
github.com/boombuler/barcode v1.0.0
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1
|
||||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
|
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user