forked from webrpc/gen-golang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go.tmpl
40 lines (34 loc) · 1001 Bytes
/
types.go.tmpl
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
{{define "types"}}
{{- $typeMap := .TypeMap -}}
{{- if .Messages -}}
//
// Types
//
{{ range .Messages -}}
{{- if isEnumType .Type }}
{{template "enum" .}}
{{ end -}}
{{- if isStructType .Type }}
{{template "struct" dict "Struct" . "TypeMap" $typeMap}}
{{ end -}}
{{- end -}}
{{- end -}}
{{- if .Services -}}
{{range .Services}}
type {{.Name}} interface {
{{- range $_, $method := .Methods}}
{{.Name}}(ctx context.Context{{range $_, $input := .Inputs}}, {{$input.Name}} {{template "type" dict "Type" $input.Type "Optional" $input.Optional "TypeMap" $typeMap}}{{end}}) {{if len .Outputs}}({{end}}{{range $i, $output := .Outputs}}{{template "type" dict "Type" $output.Type "Optional" $output.Optional "TypeMap" $typeMap}}{{if lt $i (len $method.Outputs)}}, {{end}}{{end}}error{{if len .Outputs}}){{end}}
{{- end}}
}
{{end}}
var WebRPCServices = map[string][]string{
{{- range .Services}}
"{{.Name}}": {
{{- range .Methods}}
"{{.Name}}",
{{- end}}
},
{{- end}}
}
{{- end -}}
{{- end -}}