diff --git a/_examples/golang-basics/example.gen.go b/_examples/golang-basics/example.gen.go index 0214c0b..a2f25c2 100644 --- a/_examples/golang-basics/example.gen.go +++ b/_examples/golang-basics/example.gen.go @@ -224,40 +224,47 @@ type GenVersions struct { SchemaVersion string `json:"SchemaVersion"` } -var ( - methods = map[string]method{ - "/rpc/ExampleService/Ping": { - Name: "Ping", - Service: "ExampleService", - Annotations: map[string]string{}, - }, - "/rpc/ExampleService/Status": { - Name: "Status", - Service: "ExampleService", - Annotations: map[string]string{"internal": ""}, - }, - "/rpc/ExampleService/Version": { - Name: "Version", - Service: "ExampleService", - Annotations: map[string]string{}, - }, - "/rpc/ExampleService/GetUser": { - Name: "GetUser", - Service: "ExampleService", - Annotations: map[string]string{"deprecated": ""}, - }, - "/rpc/ExampleService/FindUser": { - Name: "FindUser", - Service: "ExampleService", - Annotations: map[string]string{}, - }, - "/rpc/ExampleService/LogEvent": { - Name: "LogEvent", - Service: "ExampleService", - Annotations: map[string]string{}, - }, +var methods = map[string]method{ + "/rpc/ExampleService/Ping": { + Name: "Ping", + Service: "ExampleService", + Annotations: map[string]string{}, + }, + "/rpc/ExampleService/Status": { + Name: "Status", + Service: "ExampleService", + Annotations: map[string]string{"internal": ""}, + }, + "/rpc/ExampleService/Version": { + Name: "Version", + Service: "ExampleService", + Annotations: map[string]string{}, + }, + "/rpc/ExampleService/GetUser": { + Name: "GetUser", + Service: "ExampleService", + Annotations: map[string]string{"deprecated": ""}, + }, + "/rpc/ExampleService/FindUser": { + Name: "FindUser", + Service: "ExampleService", + Annotations: map[string]string{}, + }, + "/rpc/ExampleService/LogEvent": { + Name: "LogEvent", + Service: "ExampleService", + Annotations: map[string]string{}, + }, +} + +func WebrpcMethods() map[string]method { + res := make(map[string]method, len(methods)) + for k, v := range methods { + res[k] = v } -) + + return res +} var WebRPCServices = map[string][]string{ "ExampleService": { diff --git a/_examples/golang-imports/api.gen.go b/_examples/golang-imports/api.gen.go index e6b7bb9..3a7158f 100644 --- a/_examples/golang-imports/api.gen.go +++ b/_examples/golang-imports/api.gen.go @@ -139,25 +139,32 @@ func (x *Location) Is(values ...Location) bool { return false } -var ( - methods = map[string]method{ - "/rpc/ExampleAPI/Ping": { - Name: "Ping", - Service: "ExampleAPI", - Annotations: map[string]string{}, - }, - "/rpc/ExampleAPI/Status": { - Name: "Status", - Service: "ExampleAPI", - Annotations: map[string]string{}, - }, - "/rpc/ExampleAPI/GetUsers": { - Name: "GetUsers", - Service: "ExampleAPI", - Annotations: map[string]string{}, - }, +var methods = map[string]method{ + "/rpc/ExampleAPI/Ping": { + Name: "Ping", + Service: "ExampleAPI", + Annotations: map[string]string{}, + }, + "/rpc/ExampleAPI/Status": { + Name: "Status", + Service: "ExampleAPI", + Annotations: map[string]string{}, + }, + "/rpc/ExampleAPI/GetUsers": { + Name: "GetUsers", + Service: "ExampleAPI", + Annotations: map[string]string{}, + }, +} + +func WebrpcMethods() map[string]method { + res := make(map[string]method, len(methods)) + for k, v := range methods { + res[k] = v } -) + + return res +} var WebRPCServices = map[string][]string{ "ExampleAPI": { diff --git a/types.go.tmpl b/types.go.tmpl index ae96771..9776cc8 100644 --- a/types.go.tmpl +++ b/types.go.tmpl @@ -29,23 +29,26 @@ {{- end }} -var ( - methods = map[string]method{ - {{- range $_, $service := $services -}} - {{- range $_, $method := $service.Methods }} - "/rpc/{{$service.Name}}/{{$method.Name}}": { - Name: "{{$method.Name}}", - Service: "{{$service.Name}}", - Annotations: map[string]string{ - {{- range $_, $annotation := $method.Annotations -}} - "{{$annotation.AnnotationType}}": "{{$annotation.Value}}", - {{- end -}} - }, - }, - {{- end -}} - {{ end }} +var methods = map[string]method{ + {{- range $_, $service := $services -}} + {{- range $_, $method := $service.Methods }} + "/rpc/{{$service.Name}}/{{$method.Name}}": { + Name: "{{$method.Name}}", + Service: "{{$service.Name}}", + Annotations: map[string]string{ {{- range $_, $annotation := $method.Annotations -}}"{{$annotation.AnnotationType}}": "{{$annotation.Value}}", {{- end -}} }, + }, + {{- end -}} + {{ end }} +} + +func WebrpcMethods() map[string]method { + res := make(map[string]method, len(methods)) + for k, v := range methods { + res[k] = v } -) + + return res +} var WebRPCServices = map[string][]string{ {{- range $_, $service := $services}}