Skip to content

Commit 6d1fe8f

Browse files
fix: added default methods to grpc code generation
1 parent 445fe3c commit 6d1fe8f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

internal/languages/golang/models.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,22 @@ func (n *LGolangNode) FillDefaults() error {
3636
}
3737
}
3838
}
39+
if n.LanguageNode.GrpcConfig != nil && n.LanguageNode.GrpcConfig.Server != nil && n.LanguageNode.GrpcConfig.Server.Resources != nil {
40+
for _, resource := range n.LanguageNode.GrpcConfig.Server.Resources {
41+
if resource.AllowedMethods == nil {
42+
defaultMethods := []string{"GET", "POST", "PUT", "DELETE"}
43+
stringPointers := func() []*string {
44+
s := make([]*string, len(defaultMethods))
45+
for i := range defaultMethods {
46+
s[i] = &defaultMethods[i]
47+
}
48+
return s
49+
}()
50+
51+
resource.AllowedMethods = stringPointers
52+
}
53+
}
54+
}
3955
}
4056
return nil
4157
}

0 commit comments

Comments
 (0)