partage

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

commit 22892d19110410cb9095ea54f6651dc49895f639
parent 5f15801b0cc3b91c61e0829be1f691d155f93e61
Author: Willy Goiffon <dev@z3bra.org>
Date:   Mon, 11 Oct 2021 15:30:16 +0200

Serve files as-is for context "/f/"

Diffstat:
Mpartage.go | 5++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/partage.go b/partage.go @@ -15,6 +15,7 @@ var conf struct { filepath string rootdir string baseuri string + filectx string maxsize int64 } @@ -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": @@ -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) }