Skip to content

Commit

Permalink
Merge pull request #51 from sea-team/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
newpanjing authored Jul 24, 2022
2 parents 7bf0787 + 4c6a67f commit 7d725c5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
14 changes: 7 additions & 7 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ curl -H "Content-Type:application/json" -X POST --data '{"id":88888,"text":"深

## 删除索引

| 接口地址 | /api/remove |
|------|------------------|
| 请求方式 | POST |
| 请求类型 | application/json |
| 接口地址 | /api/index/remove |
| -------- | ----------------- |
| 请求方式 | POST |
| 请求类型 | application/json |

### 请求

Expand Down Expand Up @@ -351,9 +351,9 @@ curl http://127.0.0.1:5678/api/status

## 删除数据库

| 接口地址 | /api/drop |
|------|-----------|
| 请求方式 | GET |
| 接口地址 | /api/db/drop |
| -------- | ------------ |
| 请求方式 | GET |

### 请求

Expand Down
7 changes: 7 additions & 0 deletions searcher/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,3 +234,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{}{})
}
8 changes: 8 additions & 0 deletions web/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"gofound/web/admin"
"gofound/web/middleware"
"log"
"mime"
"strings"

"github.com/gin-contrib/gzip"
Expand Down Expand Up @@ -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...)
Expand Down

0 comments on commit 7d725c5

Please sign in to comment.