added more form functions

This commit is contained in:
2023-03-26 20:19:31 +02:00
parent 0af31bb0d9
commit 07bb5569a7
10 changed files with 200 additions and 91 deletions

View File

@@ -65,6 +65,7 @@ func Execute() error {
f.StringVarP(&conf.Super, "super", "", "", "The API Context which has permissions on all contexts")
f.StringVarP(&conf.Frontpage, "frontpage", "", "welcome to upload api, use /api enpoint!",
"Content or filename to be displayed on / in case someone visits")
f.StringVarP(&conf.Formpage, "formpage", "", "", "Content or filename to be displayed for forms (must be a go template)")
// server settings
f.BoolVarP(&conf.V4only, "ipv4", "4", false, "Only listen on ipv4")
@@ -142,6 +143,20 @@ func Execute() error {
}
}
// Formpage?
if conf.Formpage != "" {
if _, err := os.Stat(conf.Formpage); err == nil {
// it's a filename, try to use it
content, err := ioutil.ReadFile(conf.Formpage)
if err != nil {
return errors.New("error loading config: " + err.Error())
}
// replace the filename
conf.Formpage = string(content)
}
}
switch {
case ShowVersion:
fmt.Println(cfg.Getversion())