Merge pull request #74 from pmoroney/master

Add httpBody helper function
This commit is contained in:
Manfred Touron 2017-09-19 21:29:51 +00:00 committed by GitHub
commit fe71150b76

View File

@ -99,6 +99,7 @@ var ProtoHelpersFuncMap = template.FuncMap{
"namespacedFlowType": namespacedFlowType, "namespacedFlowType": namespacedFlowType,
"httpVerb": httpVerb, "httpVerb": httpVerb,
"httpPath": httpPath, "httpPath": httpPath,
"httpBody": httpBody,
"shortType": shortType, "shortType": shortType,
"urlHasVarsFromMessage": urlHasVarsFromMessage, "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 { func urlHasVarsFromMessage(path string, d *ggdescriptor.Message) bool {
for _, field := range d.Field { for _, field := range d.Field {
if !isFieldMessage(field) { if !isFieldMessage(field) {