/
lib_httpserver.go
executable file
·111 lines (84 loc) · 2.4 KB
/
lib_httpserver.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package autogen
// AUTO GENERATED CODE DO NOT MODIFY MANUALLY
import (
"net/http/httptest"
"github.com/cloudwan/gohan/extension/gohanscript"
"github.com/cloudwan/gohan/extension/gohanscript/lib"
)
func init() {
gohanscript.RegisterStmtParser("get_test_server_url",
func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
return func(context *gohanscript.Context) (interface{}, error) {
var server *httptest.Server
iserver := stmt.Arg("server", context)
if iserver != nil {
server = iserver.(*httptest.Server)
}
result1 :=
lib.GetTestServerURL(
server)
return result1, nil
}, nil
})
gohanscript.RegisterMiniGoFunc("GetTestServerURL",
func(vm *gohanscript.VM, args []interface{}) []interface{} {
server, _ := args[0].(*httptest.Server)
result1 :=
lib.GetTestServerURL(
server)
return []interface{}{
result1}
})
gohanscript.RegisterStmtParser("stop_test_server",
func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
return func(context *gohanscript.Context) (interface{}, error) {
var server *httptest.Server
iserver := stmt.Arg("server", context)
if iserver != nil {
server = iserver.(*httptest.Server)
}
lib.StopTestServer(
server)
return nil, nil
}, nil
})
gohanscript.RegisterMiniGoFunc("StopTestServer",
func(vm *gohanscript.VM, args []interface{}) []interface{} {
server, _ := args[0].(*httptest.Server)
lib.StopTestServer(
server)
return nil
})
gohanscript.RegisterStmtParser("gohan_server",
func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
return func(context *gohanscript.Context) (interface{}, error) {
var configFile string
iconfigFile := stmt.Arg("config_file", context)
if iconfigFile != nil {
configFile = iconfigFile.(string)
}
var test bool
itest := stmt.Arg("test", context)
if itest != nil {
test = itest.(bool)
}
result1,
err :=
lib.GohanServer(
configFile, test)
return result1, err
}, nil
})
gohanscript.RegisterMiniGoFunc("GohanServer",
func(vm *gohanscript.VM, args []interface{}) []interface{} {
configFile, _ := args[0].(string)
test, _ := args[0].(bool)
result1,
err :=
lib.GohanServer(
configFile, test)
return []interface{}{
result1,
err}
})
}