Skip to content

Commit

Permalink
prevent nil panics
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasJenicek committed Sep 30, 2024
1 parent 2029ca9 commit 037db71
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion helpers.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 037db71

Please sign in to comment.