partage

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.z3bra.org/partage.git
Log | Files | Refs | README | LICENSE

commit 37da75033a0a9d517cfa5fe4ec2cc7abe354431c
parent 5ed4fb1dbaec34335e0521088e4e62dfea0bcb63
Author: Willy Goiffon <dev@z3bra.org>
Date:   Wed, 20 Oct 2021 10:34:26 +0200

Provide different output methods

Diffstat:
Mpartage.go | 9++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/partage.go b/partage.go @@ -203,11 +203,14 @@ func uploaderPost(w http.ResponseWriter, r *http.Request) { links = append(links, link) } - if r.PostFormValue("output") == "html" { + switch r.PostFormValue("output") { + case "html": data := templatedata{Links: links} servetemplate(w, "/upload.html", data) - return - } else { + case "json": + data, _ := json.Marshal(links) + w.Write(data) + default: for _, link := range links { w.Write([]byte(link + "\r\n")) }