diff --git a/helpers.go.tmpl b/helpers.go.tmpl index 3a7f2ad..99384d3 100644 --- a/helpers.go.tmpl +++ b/helpers.go.tmpl @@ -54,7 +54,10 @@ func RequestFromContext(ctx context.Context) *http.Request { func MethodFromContext(ctx context.Context) MethodCtx { name, _ := ctx.Value(MethodNameCtxKey).(string) service, _ := ctx.Value(ServiceNameCtxKey).(string) - annotations, _ := ctx.Value(methodAnnotationsCtxKey).(map[string]string) + annotations, ok := ctx.Value(methodAnnotationsCtxKey).(map[string]string) + if !ok { + annotations = map[string]string{} + } return MethodCtx{ Name: name, diff --git a/server.go.tmpl b/server.go.tmpl index 5c0a77a..6589f00 100644 --- a/server.go.tmpl +++ b/server.go.tmpl @@ -71,7 +71,7 @@ func (s *{{$serviceName}}) ServeHTTP(w http.ResponseWriter, r *http.Request) { switch contentType { case "application/json": - if s.OnRequest != nil { + if s.OnRequest != nil { if err := s.OnRequest(w, r); err != nil { rpcErr, ok := err.(WebRPCError) if !ok { @@ -80,7 +80,7 @@ func (s *{{$serviceName}}) ServeHTTP(w http.ResponseWriter, r *http.Request) { s.sendErrorJSON(w, r, rpcErr) return } - } + } handler(ctx, w, r) default: