Merge pull request #74 from pmoroney/master
Add httpBody helper function
This commit is contained in:
commit
fe71150b76
@ -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) {
|
||||||
|
Loading…
Reference in New Issue
Block a user