partage

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

commit 6ab4569d7e374f7da6055fe3f04a93e1bc9a3dc8
parent 47748d678a02b48e37f607d670bca067d6d7d59c
Author: Willy Goiffon <dev@z3bra.org>
Date:   Sun, 17 Oct 2021 18:14:58 +0200

Turn all config options into flags

Diffstat:
Mpartage.go | 17++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/partage.go b/partage.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "flag" "io" "io/ioutil" "net/http" @@ -219,13 +220,15 @@ func uploader(w http.ResponseWriter, r *http.Request) { } func main() { - conf.bind = "0.0.0.0:8080" - conf.maxsize = 30064771072 // 28Gib - conf.filepath = "/tmp" - conf.rootdir = "./static" - conf.baseuri = "http://192.168.0.3:8080" - conf.filectx = "/f/" - conf.templatedir = "./templates" + flag.StringVar(&conf.bind, "l", "0.0.0.0:8080", "Address to bind to (default: 0.0.0.0:8080)") + flag.StringVar(&conf.baseuri, "b", "http://127.0.0.1:8080", "Base URI to use for links (default: http://127.0.0.1:8080)") + flag.StringVar(&conf.filepath, "f", "/tmp", "Path to save files to (default: /tmp)") + flag.StringVar(&conf.filectx, "c", "/f/", "Context to serve files from (default: /f/)") + flag.StringVar(&conf.rootdir, "r", "./static", "Root directory (default: ./static)") + flag.StringVar(&conf.templatedir, "t", "./templates", "Templates directory (default: ./templates)") + flag.Int64Var(&conf.maxsize, "s", 30064771072, "Maximum file size (default: 28Gib)") + + flag.Parse() http.HandleFunc("/", uploader) http.Handle(conf.filectx, http.StripPrefix(conf.filectx, http.FileServer(http.Dir(conf.filepath))))