Add httpBody helper function
This commit is contained in:
parent
a0e68f8a2b
commit
7172d5b49d
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user