+ ProcessPing

This commit is contained in:
Max 2021-09-28 11:13:59 +08:00
parent f78d9e26cb
commit 270fffe3a7
3 changed files with 40 additions and 1 deletions

22
global/process.go Normal file
View file

@ -0,0 +1,22 @@
package global
import (
"github.com/yaoapp/gou"
)
// 注册处理器
func init() {
gou.RegisterProcessHandler("xiang.global.ping", processPing)
}
// processCreate 运行模型 MustCreate
func processPing(process *gou.Process) interface{} {
res := map[string]interface{}{
"code": 200,
"server": "象传应用引擎",
"version": VERSION,
"domain": DOMAIN,
"allows": Conf.Service.Allow,
}
return res
}

17
global/process_test.go Normal file
View file

@ -0,0 +1,17 @@
package global
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/yaoapp/gou"
)
func TestProcessPing(t *testing.T) {
process := gou.Process{
Name: "xiang.global.ping",
}
res, ok := processPing(&process).(map[string]interface{})
assert.True(t, ok)
assert.Equal(t, res["version"], VERSION)
}

View file

@ -9,7 +9,7 @@
"path": "/ping",
"method": "GET",
"guard": "-",
"process": "xiang.ping",
"process": "xiang.global.ping",
"in": [],
"out": {
"status": 200,