+ ProcessPing
This commit is contained in:
parent
f78d9e26cb
commit
270fffe3a7
3 changed files with 40 additions and 1 deletions
22
global/process.go
Normal file
22
global/process.go
Normal 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
17
global/process_test.go
Normal 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)
|
||||||
|
}
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
"path": "/ping",
|
"path": "/ping",
|
||||||
"method": "GET",
|
"method": "GET",
|
||||||
"guard": "-",
|
"guard": "-",
|
||||||
"process": "xiang.ping",
|
"process": "xiang.global.ping",
|
||||||
"in": [],
|
"in": [],
|
||||||
"out": {
|
"out": {
|
||||||
"status": 200,
|
"status": 200,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue