From d40bfbc824f9cff8014ca74c68e5e5424649c9d7 Mon Sep 17 00:00:00 2001 From: Lukas Jenicek Date: Fri, 27 Sep 2024 12:11:56 +0200 Subject: [PATCH] rename to MethodAnnotationsFromCtx --- _examples/golang-basics/example.gen.go | 27 +++++++++++++------------- _examples/golang-imports/api.gen.go | 23 +++++++++++----------- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/_examples/golang-basics/example.gen.go b/_examples/golang-basics/example.gen.go index ebabb62..13fd55b 100644 --- a/_examples/golang-basics/example.gen.go +++ b/_examples/golang-basics/example.gen.go @@ -1,6 +1,6 @@ // example v0.0.1 9d2e85c0083323599454454bc06526ab08edd24e // -- -// Code generated by webrpc-gen@v0.19.3-8-g87b50a2 with ../../../gen-golang generator. DO NOT EDIT. +// Code generated by webrpc-gen@v0.19.3-9-g1ee375b 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 @@ -160,6 +160,17 @@ type ComplexType struct { User *User `json:"user"` } +var ( + methodAnnotations = map[string]map[string]string{ + "/rpc/ExampleService/Ping": {}, + "/rpc/ExampleService/Status": {}, + "/rpc/ExampleService/Version": {}, + "/rpc/ExampleService/GetUser": {}, + "/rpc/ExampleService/FindUser": {}, + "/rpc/ExampleService/LogEvent": {}, + } +) + var WebRPCServices = map[string][]string{ "ExampleService": { "Ping", @@ -211,20 +222,10 @@ type WebRPCServer interface { http.Handler } -var ( - annotations = map[string]map[string]string{ - "/rpc/ExampleService/Ping": {}, - "/rpc/ExampleService/Status": {}, - "/rpc/ExampleService/Version": {}, - "/rpc/ExampleService/GetUser": {}, - "/rpc/ExampleService/FindUser": {}, - "/rpc/ExampleService/LogEvent": {}} -) - type exampleServiceServer struct { ExampleService OnError func(r *http.Request, rpcErr *WebRPCError) - OnRequest func(w http.ResponseWriter, r *http.Request) + OnRequest func(w http.ResponseWriter, r *http.Request) error } func NewExampleServiceServer(svc ExampleService) *exampleServiceServer { @@ -801,7 +802,7 @@ func RequestFromContext(ctx context.Context) *http.Request { return r } -func AnnotationsFromContext(ctx context.Context) map[string]string { +func MethodAnnotationsFromContext(ctx context.Context) map[string]string { annotations, _ := ctx.Value(AnnotationsCtxKey).(map[string]string) return annotations } diff --git a/_examples/golang-imports/api.gen.go b/_examples/golang-imports/api.gen.go index f717b10..3fe9736 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-8-g87b50a2 with ../../../gen-golang generator. DO NOT EDIT. +// Code generated by webrpc-gen@v0.19.3-9-g1ee375b 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 @@ -82,7 +82,15 @@ func (x *Location) Is(values ...Location) bool { } } return false -} +}var ( + methodAnnotations = map[string]map[string]string{ + "/rpc/ExampleAPI/Ping": {}, + "/rpc/ExampleAPI/Status": {}, + "/rpc/ExampleAPI/GetUsers": {}, + } +) + + var WebRPCServices = map[string][]string{ "ExampleAPI": { @@ -126,17 +134,10 @@ type WebRPCServer interface { http.Handler } -var ( - annotations = map[string]map[string]string{ - "/rpc/ExampleAPI/Ping": {}, - "/rpc/ExampleAPI/Status": {}, - "/rpc/ExampleAPI/GetUsers": {},} -) - type exampleAPIServer struct { ExampleAPI OnError func(r *http.Request, rpcErr *WebRPCError) - OnRequest func(w http.ResponseWriter, r *http.Request) + OnRequest func(w http.ResponseWriter, r *http.Request) error } func NewExampleAPIServer(svc ExampleAPI) *exampleAPIServer { @@ -539,7 +540,7 @@ func RequestFromContext(ctx context.Context) *http.Request { return r } -func AnnotationsFromContext(ctx context.Context) map[string]string { +func MethodAnnotationsFromContext(ctx context.Context) map[string]string { annotations, _ := ctx.Value(AnnotationsCtxKey).(map[string]string) return annotations }