@@ -10,12 +10,11 @@ import (
1010)
1111
1212func Get (m protoreflect.MethodDescriptor ) (* annotations.HttpRule , bool ) {
13- if descriptors , ok := proto .GetExtension (
14- m .Options (), annotations .E_Http ,
15- ).(* annotations.HttpRule ); ok {
16- return descriptors , true
13+ descriptor , ok := proto .GetExtension (m .Options (), annotations .E_Http ).(* annotations.HttpRule )
14+ if ! ok || descriptor == nil {
15+ return nil , false
1716 }
18- return nil , false
17+ return descriptor , true
1918}
2019
2120type Rule struct {
@@ -57,7 +56,7 @@ func ParseRule(httpRule *annotations.HttpRule) (Rule, error) {
5756}
5857
5958func httpRuleURL (rule * annotations.HttpRule ) (string , error ) {
60- switch v := rule .Pattern .(type ) {
59+ switch v := rule .GetPattern () .(type ) {
6160 case * annotations.HttpRule_Get :
6261 return v .Get , nil
6362 case * annotations.HttpRule_Post :
@@ -76,7 +75,7 @@ func httpRuleURL(rule *annotations.HttpRule) (string, error) {
7675}
7776
7877func httpRuleMethod (rule * annotations.HttpRule ) (string , error ) {
79- switch v := rule .Pattern .(type ) {
78+ switch v := rule .GetPattern () .(type ) {
8079 case * annotations.HttpRule_Get :
8180 return http .MethodGet , nil
8281 case * annotations.HttpRule_Post :
0 commit comments