mirror of
https://codeberg.org/scip/ephemerup.git
synced 2025-12-18 21:11:04 +01:00
added more form functions
This commit is contained in:
15
cmd/root.go
15
cmd/root.go
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user