diff --git a/helpers/helpers.go b/helpers/helpers.go index 1721c3b..72d8aeb 100644 --- a/helpers/helpers.go +++ b/helpers/helpers.go @@ -99,6 +99,7 @@ var ProtoHelpersFuncMap = template.FuncMap{ "namespacedFlowType": namespacedFlowType, "httpVerb": httpVerb, "httpPath": httpPath, + "httpBody": httpBody, "shortType": shortType, "urlHasVarsFromMessage": urlHasVarsFromMessage, } @@ -427,6 +428,19 @@ func httpVerb(m *descriptor.MethodDescriptorProto) string { } } +func httpBody(m *descriptor.MethodDescriptorProto) string { + + ext, err := proto.GetExtension(m.Options, options.E_Http) + if err != nil { + return err.Error() + } + opts, ok := ext.(*options.HttpRule) + if !ok { + return fmt.Sprintf("extension is %T; want an HttpRule", ext) + } + return opts.Body +} + func urlHasVarsFromMessage(path string, d *ggdescriptor.Message) bool { for _, field := range d.Field { if !isFieldMessage(field) {