diff --git a/searcher/utils/utils.go b/searcher/utils/utils.go index b2d04ce..8579898 100644 --- a/searcher/utils/utils.go +++ b/searcher/utils/utils.go @@ -227,3 +227,10 @@ func RemoveSpace(str string) string { reg := regexp.MustCompile(`\s+`) return reg.ReplaceAllString(str, "") } + +// init 注册数据类型 +// 防止 gob: type not registered for interface: map[string]interface {} +func init() { + gob.Register(map[string]interface{}{}) + gob.Register([]interface{}{}) +} diff --git a/web/router/router.go b/web/router/router.go index 9ad86ed..e298c68 100644 --- a/web/router/router.go +++ b/web/router/router.go @@ -5,6 +5,7 @@ import ( "gofound/web/admin" "gofound/web/middleware" "log" + "mime" "strings" "github.com/gin-contrib/gzip" @@ -38,6 +39,13 @@ func SetupRouter() *gin.Engine { log.Println("Enable Auth:", global.CONFIG.Auth) } + // 告诉服务.js文件的MIME类型 + err := mime.AddExtensionType(".js", "application/javascript") + // 如果存在错误则需要马上抛出 + if err != nil { + panic("添加扩展类型 mime 错误,错误原因:" + err.Error()) + } + //注册admin if global.CONFIG.EnableAdmin { admin.Register(router, handlers...)