models.go 1.3 KB
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
}
`