Commit a4b760ec authored by 赵文静's avatar 赵文静

增加AppKey

parent 463d829d
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
- 增加音乐专辑字段 - 增加音乐专辑字段
- 修改日志打印 - 修改日志打印
- 故事返回增加专辑字段 - 故事返回增加专辑字段
- http入口新增需要AppKey校验
## [0.0.1-beta.3] - 2025.6.19 ## [0.0.1-beta.3] - 2025.6.19
### Changed ### Changed
......
POST https://testnlu.gree.com/semantic/unisoundc2c/child/querys
#POST http://localhost:19992/semantic/unisoundc2c/child/querys/v2
Content-Type: application/json
{
"reqParam": {
"common": {
"remoteIP": "14.215.222.17",
"trafficParameter": "ver=3.0;scenario=smarthome;filterName=nlu2;req_nlu_length=2;returnType=json;fullDuplex=true;appendLength=1;additionalService=geli_nlu;mid=10f04;version=0.5;macWifi=28b77c23817b;macVoice=28b77c23817b"
},
"nluRet": {
"asr_recongize": "",
"text": "暂停闹钟"
}
},
"version": "v0"
}
###
POST https://testnlu.gree.com/semantic/unisoundc2c/speech-nlu-parse POST https://testnlu.gree.com/semantic/unisoundc2c/speech-nlu-parse
Content-Type: application/json Content-Type: application/json
...@@ -5,7 +24,7 @@ Content-Type: application/json ...@@ -5,7 +24,7 @@ Content-Type: application/json
"ip": "14.215.222.17", "ip": "14.215.222.17",
"mac": "ece154a865eb", "mac": "ece154a865eb",
"mid": "11011", "mid": "11011",
"query":"我想听儿歌", "query":"暂停闹钟",
"requestId": "123456111" "requestId": "123456111"
} }
...@@ -13,6 +32,7 @@ Content-Type: application/json ...@@ -13,6 +32,7 @@ Content-Type: application/json
#POST http://172.28.54.27:13302/semantic/unisoundc2c/speech-nlu-parse #POST http://172.28.54.27:13302/semantic/unisoundc2c/speech-nlu-parse
POST http://172.28.124.110:13302/semantic/unisoundc2c/speech-nlu-parse POST http://172.28.124.110:13302/semantic/unisoundc2c/speech-nlu-parse
Content-Type: application/json Content-Type: application/json
X-AppKey: 391b50b5ed634fc49a3db7cfd6bc40db
{ {
"ip": "14.215.222.17", "ip": "14.215.222.17",
...@@ -39,7 +59,7 @@ Content-Type: application/json ...@@ -39,7 +59,7 @@ Content-Type: application/json
"trafficParameter": "mode=childxxx;macWifi=28b77c218ed1;mid=10f05;vender=7e000025;macVoice=testyuntiancloud;ver=3.0;scenario=smarthome;filterName=nlu;req_nlu_length=1;returnType=json;fullDuplex=true;appendLength=1;additionalService=geli_nlu2;version=0.5;filterUrl=https://testnlu.gree.com:443/semantic/unisoundc2c/querys;" "trafficParameter": "mode=childxxx;macWifi=28b77c218ed1;mid=10f05;vender=7e000025;macVoice=testyuntiancloud;ver=3.0;scenario=smarthome;filterName=nlu;req_nlu_length=1;returnType=json;fullDuplex=true;appendLength=1;additionalService=geli_nlu2;version=0.5;filterUrl=https://testnlu.gree.com:443/semantic/unisoundc2c/querys;"
}, },
"nluRet": { "nluRet": {
"text": "播放音乐" "text": "暂停闹钟"
}, },
"postProc": {} "postProc": {}
} }
...@@ -80,7 +100,7 @@ Content-Type: application/json ...@@ -80,7 +100,7 @@ Content-Type: application/json
"trafficParameter": "mode=childxx;macWifi=ece154a73d38;mid=11011;macVoice=testyuntiancloud;ver=3.0;scenario=smarthome;filterName=nlu;req_nlu_length=1;returnType=json;fullDuplex=true;appendLength=1;additionalService=geli_nlu2;version=0.5;filterUrl=https://testnlu.gree.com:443/semantic/unisoundc2c/querys;" "trafficParameter": "mode=childxx;macWifi=ece154a73d38;mid=11011;macVoice=testyuntiancloud;ver=3.0;scenario=smarthome;filterName=nlu;req_nlu_length=1;returnType=json;fullDuplex=true;appendLength=1;additionalService=geli_nlu2;version=0.5;filterUrl=https://testnlu.gree.com:443/semantic/unisoundc2c/querys;"
}, },
"nluRet": { "nluRet": {
"text": "播放故事" "text": "暂停闹钟"
}, },
"postProc": {} "postProc": {}
} }
......
...@@ -5,6 +5,7 @@ import ( ...@@ -5,6 +5,7 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/tidwall/gjson" "github.com/tidwall/gjson"
"net/http"
"speech-nlu-parse/app" "speech-nlu-parse/app"
"speech-nlu-parse/global" "speech-nlu-parse/global"
"speech-nlu-parse/model" "speech-nlu-parse/model"
...@@ -20,6 +21,9 @@ func InitRouter() (engine *gin.Engine) { ...@@ -20,6 +21,9 @@ func InitRouter() (engine *gin.Engine) {
engine = gin.New() engine = gin.New()
engine.Use(gin.Recovery()) engine.Use(gin.Recovery())
// 校验AppKey
engine.Use(VerifyAppKeyMiddleware())
// 超时限制测试 // 超时限制测试
//engine.Use(middleware.TimeLimitMiddleware(time.Second * 5)) //engine.Use(middleware.TimeLimitMiddleware(time.Second * 5))
engine.POST(global.ServerSetting.UriPath, Controller) engine.POST(global.ServerSetting.UriPath, Controller)
...@@ -84,3 +88,30 @@ func SpeechNluParseSemanticRequest(req SnpReq) *model.SemanticReq { ...@@ -84,3 +88,30 @@ func SpeechNluParseSemanticRequest(req SnpReq) *model.SemanticReq {
return semanticReq return semanticReq
} }
// 校验AppKey
func VerifyAppKeyMiddleware() gin.HandlerFunc {
validAppKeys := map[string]bool{
"391b50b5ed634fc49a3db7cfd6bc40db": true,
}
return func(c *gin.Context) {
appKey := c.GetHeader("X-AppKey")
if appKey == "" {
c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{
"error": "App key is required",
})
return
}
if !validAppKeys[appKey] {
c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{
"error": "Invalid app key",
})
return
}
c.Next()
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment