浏览代码

hammering out issues for both implementations

svcs 1 年之前
父节点
当前提交
200b480ed0
共有 3 个文件被更改,包括 11 次插入6 次删除
  1. 2 0
      .gitignore
  2. 2 1
      pkg/configuration.go
  3. 7 5
      pkg/controller.go

+ 2 - 0
.gitignore

@@ -40,6 +40,8 @@ config/routemaps/*
 config/pagemod/*
 config/rsc/*
 config/fileserver/*
+config/*.config
+config/*.json
 
 # cookies.json file
 cookies.json

+ 2 - 1
pkg/configuration.go

@@ -160,7 +160,8 @@ Read in the custom file server configuration
 func ReadCustomFiles(loc string) *CustomFileServer {
 	b, err := os.ReadFile(loc)
 	if err != nil {
-		log.Fatal("couldnt read custom config file: ", err)
+		fmt.Printf("couldnt read custom config file: %s\n", err.Error())
+		return nil
 	}
 	var fserveCfg CustomFileServer
 	err = json.Unmarshal(b, &fserveCfg)

+ 7 - 5
pkg/controller.go

@@ -108,11 +108,13 @@ func (c *Controller) HandleAny(ctx *gin.Context) {
 			return
 		}
 	}
-	for idx := range c.Config.CustomFserve.Config {
-		if incomingPath == c.Config.CustomFserve.Config[idx].Request {
-			fmt.Print("Custom file server path hit.\n")
-			ctx.Data(200, c.Config.CustomFserve.Config[idx].ContentType, c.Config.CustomFserve.Config[idx].FileData)
-			return
+	if c.Config.CustomFserve != nil {
+		for idx := range c.Config.CustomFserve.Config {
+			if incomingPath == c.Config.CustomFserve.Config[idx].Request {
+				fmt.Print("Custom file server path hit.\n")
+				ctx.Data(200, c.Config.CustomFserve.Config[idx].ContentType, c.Config.CustomFserve.Config[idx].FileData)
+				return
+			}
 		}
 	}
 	if c.Config.Caching {