removed hard coded values

This commit is contained in:
dtookey 2023-07-31 17:02:31 -04:00
parent 465266c36d
commit e619a9f609

View File

@ -34,6 +34,13 @@ type (
}
)
const (
defaultTemplateFileName = "servlet.json.example.tmpl"
defaultListeningPort = ":8080"
defaultUrlPattern = "/*"
defaultFileLocation = "errors/"
)
const (
Text ConfigType = "Text"
Image = "Image"
@ -42,14 +49,14 @@ const (
func CreateBlankConfig() *Config {
conf := Config{
ListeningAddress: ":8080",
ListeningAddress: defaultListeningPort,
Routes: make([]ConfigEntry, 0, 10),
}
dummyRoute := ConfigEntry{
ConfigType: Text,
UrlPattern: "/*",
FileLocation: "errors/",
UrlPattern: defaultUrlPattern,
FileLocation: defaultFileLocation,
UseBuiltinCache: false,
}
@ -107,13 +114,12 @@ func getConstructorFunction(t ConfigType) (RouteConstructor, error) {
}
func GenerateBlankConfig() error {
fileName := "servlet.json.template.tmpl"
conf := CreateBlankConfig()
content, err := json.Marshal(&conf)
if err != nil {
return err
}
fmt.Println("Generating a blank configuration file at ")
ioutil.WriteFile(fileName, content, 0755)
ioutil.WriteFile(defaultTemplateFileName, content, 0755)
return nil
}