diff --git a/servlet/config.go b/servlet/config.go index 3800770..37f47a2 100644 --- a/servlet/config.go +++ b/servlet/config.go @@ -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 }