tServe files as-is for context "/f/" - 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 22892d19110410cb9095ea54f6651dc49895f639
 (DIR) parent 5f15801b0cc3b91c61e0829be1f691d155f93e61
 (HTM) Author: Willy Goiffon <dev@z3bra.org>
       Date:   Mon, 11 Oct 2021 15:30:16 +0200
       
       Serve files as-is for context "/f/"
       
       Diffstat:
         M partage.go                          |       5 ++++-
       
       1 file changed, 4 insertions(+), 1 deletion(-)
       ---
 (DIR) diff --git a/partage.go b/partage.go
       t@@ -15,6 +15,7 @@ var conf struct {
                filepath string
                rootdir  string
                baseuri  string
       +        filectx  string
                maxsize  int64
        }
        
       t@@ -122,7 +123,7 @@ func parse(w http.ResponseWriter, r *http.Request) {
                                return
                        }
        
       -                resp := conf.baseuri + "/" + filepath.Base(tmp.Name())
       +                resp := conf.baseuri + conf.filectx + filepath.Base(tmp.Name())
                        w.Write([]byte(resp))
        
                case "GET":
       t@@ -150,7 +151,9 @@ func main() {
                conf.filepath = "/tmp"
                conf.rootdir = "./static"
                conf.baseuri = "http://192.168.0.3:8080"
       +        conf.filectx = "/f/"
        
                http.HandleFunc("/", parse)
       +        http.Handle(conf.filectx, http.StripPrefix(conf.filectx, http.FileServer(http.Dir(conf.filepath))))
                http.ListenAndServe("0.0.0.0:8080", nil)
        }