diff --git a/_examples/golang-basics/example.gen.go b/_examples/golang-basics/example.gen.go index 6603744..179b8d1 100644 --- a/_examples/golang-basics/example.gen.go +++ b/_examples/golang-basics/example.gen.go @@ -1,6 +1,6 @@ // example v0.0.1 05b7a5c86b98738f4fe6ce9bb1fccd4af064847a // -- -// Code generated by webrpc-gen@v0.19.3-14-g132051b with ../../../gen-golang generator. DO NOT EDIT. +// Code generated by webrpc-gen@v0.19.3-15-g3735deb with ../../../gen-golang generator. DO NOT EDIT. // // webrpc-gen -schema=example.ridl -target=../../../gen-golang -pkg=main -server -client -legacyErrors -fixEmptyArrays -out=./example.gen.go package main @@ -161,13 +161,37 @@ type ComplexType struct { } var ( - methodAnnotations = map[string]map[string]string{ - "/rpc/ExampleService/Ping": {}, - "/rpc/ExampleService/Status": {"internal": ""}, - "/rpc/ExampleService/Version": {}, - "/rpc/ExampleService/GetUser": {}, - "/rpc/ExampleService/FindUser": {}, - "/rpc/ExampleService/LogEvent": {}, + methodAnnotations = map[string]MethodCtx{ + "/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{}, + }, + "/rpc/ExampleService/FindUser": { + Name: "FindUser", + Service: "ExampleService", + Annotations: map[string]string{}, + }, + "/rpc/ExampleService/LogEvent": { + Name: "LogEvent", + Service: "ExampleService", + Annotations: map[string]string{}, + }, } ) diff --git a/_examples/golang-imports/api.gen.go b/_examples/golang-imports/api.gen.go index 7222f61..b1952d3 100644 --- a/_examples/golang-imports/api.gen.go +++ b/_examples/golang-imports/api.gen.go @@ -1,6 +1,6 @@ // example-api-service v1.0.0 cae4e128f4fb4c938bfe1ea312deeea3dfd6b6af // -- -// Code generated by webrpc-gen@v0.19.3-14-g132051b with ../../../gen-golang generator. DO NOT EDIT. +// Code generated by webrpc-gen@v0.19.3-15-g3735deb with ../../../gen-golang generator. DO NOT EDIT. // // webrpc-gen -schema=./proto/api.ridl -target=../../../gen-golang -out=./api.gen.go -pkg=main -server -client -legacyErrors=true -fmt=false package main @@ -85,10 +85,22 @@ func (x *Location) Is(values ...Location) bool { } var ( - methodAnnotations = map[string]map[string]string{ - "/rpc/ExampleAPI/Ping": {}, - "/rpc/ExampleAPI/Status": {}, - "/rpc/ExampleAPI/GetUsers": {}, + methodAnnotations = map[string]MethodCtx{ + "/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{}, + }, } ) @@ -512,9 +524,9 @@ func HTTPRequestHeaders(ctx context.Context) (http.Header, bool) { // type MethodCtx struct { - Name string - Service string - Annotations map[string]string + Name string + Service string + Annotations map[string]string } type contextKey struct { diff --git a/types.go.tmpl b/types.go.tmpl index 6ec5115..adb77d8 100644 --- a/types.go.tmpl +++ b/types.go.tmpl @@ -30,13 +30,17 @@ {{- end }} var ( - methodAnnotations = map[string]map[string]string{ + methodAnnotations = map[string]MethodCtx{ {{- range $_, $service := $services -}} {{- range $_, $method := $service.Methods }} "/rpc/{{$service.Name}}/{{$method.Name}}": { - {{- range $_, $annotation := $method.Annotations -}} - "{{$annotation.AnnotationType}}": "{{$annotation.Value}}", - {{- end -}} + Name: "{{$method.Name}}", + Service: "{{$service.Name}}", + Annotations: map[string]string{ + {{- range $_, $annotation := $method.Annotations -}} + "{{$annotation.AnnotationType}}": "{{$annotation.Value}}", + {{- end -}} + }, }, {{- end -}} {{ end }}