tProvide different output methods - partage - File upload system
 (HTM) git clone git://git.z3bra.org/partage.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 37da75033a0a9d517cfa5fe4ec2cc7abe354431c
 (DIR) parent 5ed4fb1dbaec34335e0521088e4e62dfea0bcb63
 (HTM) Author: Willy Goiffon <dev@z3bra.org>
       Date:   Wed, 20 Oct 2021 10:34:26 +0200
       
       Provide different output methods
       
       Diffstat:
         M partage.go                          |       9 ++++++---
       
       1 file changed, 6 insertions(+), 3 deletions(-)
       ---
 (DIR) diff --git a/partage.go b/partage.go
       t@@ -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"))
                        }