models.go
1.3 KB
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
package main
type Schema struct {
MetaData *MetaData `json:"metadata,optional"`
}
type MetaData struct {
Name string `json:"name,optional"`
Description string `json:"description,optional"`
Attributes []*Attributes `json:"attributes,optional"`
}
type Attributes struct {
Ref string `json:"ref,optional"`
Name string `json:"name,optional"`
Description string `json:"description,optional"`
Type map[string]interface{} `json:"type,optional"`
}
type Attribute struct {
MetaDataItem *MetaDataItem `json:"metadata,optional"`
}
type MetaDataItem struct {
Name string `json:"name,optional"`
Description string `json:"description,optional"`
Type map[string]interface{} `json:"type,optional"`
}
type ApiItem struct {
Method string
Path string
//Router string
HttpMethod string
}
const gatewayTemplate =`
package gateway
const (
{{range .Routers}}
{{.Method}} = "{{.Method}}"{{end}}
)
var DefaultService *HttpDefaultServiceGateway
func init() {
DefaultService = &HttpDefaultServiceGateway{gs.NewManagerService("127.0.0.1", DefaultRouters())}
DefaultService.WithDebugModel(true)
}
type HttpDefaultServiceGateway struct {
*gs.GatewayService
}
func DefaultRouters() []gs.Router {
routers := []gs.Router{
{{range .Routers}}
{ {{.Method}}, "{{.Path}}", "{{.HttpMethod}}"},{{end}}
}
return routers
}
`