This commit is contained in:
suguo.yao 2022-10-18 14:13:53 +08:00
parent 4c1b66acdf
commit 31072894b5
2 changed files with 28 additions and 21 deletions

View File

@ -20,6 +20,7 @@ POST {{url}}/index?database=default HTTP/1.1
Authorization:
{
"id":111,
"text": "北京北三站",
"document": {
"title": "阿森松岛所245",
@ -50,14 +51,28 @@ POST {{url}}/index/batch?database=default HTTP/1.1
POST {{url}}/index/remove?database=default HTTP/1.1
{
"id":88887
"id":1420489961
}
#### 公开查询索引
POST http://192.168.0.254:5678/ HTTP/1.1
{
"query":"融七牛",
"page":1,
"limit":10,
"order": "DESC",
"highlight": {
"preTag":"<span style='color:red'>",
"postTag":"</span>"
}
}
#### 查询索引
POST {{url}}/query HTTP/1.1
{
"query":"北京",
"query":"融七牛",
"page":1,
"limit":10,
"order": "DESC",
@ -85,4 +100,4 @@ GET {{url}}/db/drop?database=aaa HTTP/1.1
GET {{url}}/db/list HTTP/1.1
#### 在线分词
GET {{url}}/word/cut?q=上海和深圳哪个城市幸福指数高 HTTP/1.1
GET {{url}}/word/cut?q=Systems Engineering Services HTTP/1.1

View File

@ -2,10 +2,10 @@ package router
import (
"log"
"mime"
"strings"
"myschools.me/suguo/gofound/global"
"myschools.me/suguo/gofound/web/controller"
"myschools.me/suguo/gofound/web/middleware"
"github.com/gin-contrib/gzip"
@ -27,27 +27,19 @@ func SetupRouter() *gin.Engine {
}
var handlers []gin.HandlerFunc
//认证
if global.CONFIG.Auth != "" {
auths := strings.Split(global.CONFIG.Auth, ":")
handlers = append(handlers, gin.BasicAuth(
gin.Accounts{
auths[0]: auths[1],
},
),
)
log.Println("Enable Auth:", global.CONFIG.Auth)
}
// 告诉服务.js文件的MIME类型
err := mime.AddExtensionType(".js", "application/javascript")
// 如果存在错误则需要马上抛出
if err != nil {
panic("添加扩展类型 mime 错误,错误原因:" + err.Error())
}
auths := strings.Split(global.CONFIG.Auth, ":")
handlers = append(handlers, gin.BasicAuth(
gin.Accounts{
auths[0]: auths[1],
},
),
)
log.Println("Enable Auth:", global.CONFIG.Auth)
// 分组管理 中间件管理
router.Use(middleware.Cors(), middleware.Exception())
router.GET("/", controller.Query)
group := router.Group("/api", handlers...)
{
InitBaseRouter(group) // 基础管理