update to how configs work
This commit is contained in:
parent
85587cd2eb
commit
577525ebaf
@ -5,6 +5,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"geniuscartel.xyz/vinegar/vinegarUtil"
|
"geniuscartel.xyz/vinegar/vinegarUtil"
|
||||||
|
"io/ioutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
@ -66,9 +67,11 @@ func LoadConfig(pathlike string) *VinegarServlet {
|
|||||||
|
|
||||||
}
|
}
|
||||||
return servlet
|
return servlet
|
||||||
|
} else {
|
||||||
|
CreateBlankConfig()
|
||||||
|
panic("Could not find config file at" + pathlike)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
panic("Could not find config file at" + pathlike)
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e ConfigEntry) toRoute(serv *VinegarServlet) {
|
func (e ConfigEntry) toRoute(serv *VinegarServlet) {
|
||||||
@ -90,3 +93,14 @@ func getConstructorFunction(t ConfigType) (RouteConstructor, error) {
|
|||||||
}
|
}
|
||||||
return nil, errors.New(fmt.Sprintf("could not determine constructor for invalid ConfigType: %s", t))
|
return nil, errors.New(fmt.Sprintf("could not determine constructor for invalid ConfigType: %s", t))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GenerateBlankConfig() {
|
||||||
|
fileName := "servlet.json.template.tmpl"
|
||||||
|
conf := CreateBlankConfig()
|
||||||
|
content, err := json.Marshal(&conf)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
fmt.Println("Generating a blank configuration file at ")
|
||||||
|
ioutil.WriteFile(fileName, content, 0755)
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user