diff --git a/servlet/config.go b/servlet/config.go index f8ccc31..2246f22 100644 --- a/servlet/config.go +++ b/servlet/config.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "geniuscartel.xyz/vinegar/vinegarUtil" + "io/ioutil" ) type ( @@ -66,9 +67,11 @@ func LoadConfig(pathlike string) *VinegarServlet { } 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) { @@ -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)) } + +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) +}