diff --git a/_examples/golang-basics/example.gen.go b/_examples/golang-basics/example.gen.go index 179b8d1..4d3a80e 100644 --- a/_examples/golang-basics/example.gen.go +++ b/_examples/golang-basics/example.gen.go @@ -839,19 +839,13 @@ func RequestFromContext(ctx context.Context) *http.Request { return r } -func MethodFromContext(ctx context.Context) MethodCtx { - name, _ := ctx.Value(MethodNameCtxKey).(string) - service, _ := ctx.Value(ServiceNameCtxKey).(string) - annotations, ok := ctx.Value(methodAnnotationsCtxKey).(map[string]string) +func GetMethodCtx(r *http.Request) (MethodCtx, bool) { + ctx, ok := methodAnnotations[r.URL.Path] if !ok { - annotations = map[string]string{} + return MethodCtx{}, false } - return MethodCtx{ - Name: name, - Service: service, - Annotations: annotations, - } + return ctx, true } func ResponseWriterFromContext(ctx context.Context) http.ResponseWriter { diff --git a/_examples/golang-imports/api.gen.go b/_examples/golang-imports/api.gen.go index b1952d3..8a8f7f7 100644 --- a/_examples/golang-imports/api.gen.go +++ b/_examples/golang-imports/api.gen.go @@ -565,19 +565,13 @@ func RequestFromContext(ctx context.Context) *http.Request { return r } -func MethodFromContext(ctx context.Context) MethodCtx { - name, _ := ctx.Value(MethodNameCtxKey).(string) - service, _ := ctx.Value(ServiceNameCtxKey).(string) - annotations, ok := ctx.Value(methodAnnotationsCtxKey).(map[string]string) +func GetMethodCtx(r *http.Request) (MethodCtx, bool) { + ctx, ok := methodAnnotations[r.URL.Path] if !ok { - annotations = map[string]string{} + return MethodCtx{}, false } - return MethodCtx{ - Name: name, - Service: service, - Annotations: annotations, - } + return ctx, true }