@@ -2,7 +2,6 @@ package main
2
2
3
3
import (
4
4
"fmt"
5
- "net/http"
6
5
"strconv"
7
6
"strings"
8
7
@@ -51,10 +50,7 @@ func generateFile(gen *protogen.Plugin, file *protogen.File) *protogen.Generated
51
50
count := 0
52
51
for _ , method := range service .Methods {
53
52
mop := method .Desc .Options ().(* descriptorpb.MethodOptions )
54
- if mop .GetDeprecated () {
55
- continue
56
- }
57
- if ! proto .HasExtension (mop , pbex .E_Method ) {
53
+ if mop .GetDeprecated () || ! proto .HasExtension (mop , pbex .E_Method ) {
58
54
continue
59
55
}
60
56
emethod := proto .GetExtension (mop , pbex .E_Method ).([]string )
@@ -101,10 +97,7 @@ func genService(file *protogen.File, s *protogen.Service, g *protogen.GeneratedF
101
97
func genPath (file * protogen.File , service * protogen.Service , g * protogen.GeneratedFile ) {
102
98
for _ , method := range service .Methods {
103
99
mop := method .Desc .Options ().(* descriptorpb.MethodOptions )
104
- if mop .GetDeprecated () {
105
- continue
106
- }
107
- if ! proto .HasExtension (mop , pbex .E_Method ) {
100
+ if mop .GetDeprecated () || ! proto .HasExtension (mop , pbex .E_Method ) {
108
101
continue
109
102
}
110
103
emethod := proto .GetExtension (mop , pbex .E_Method ).([]string )
@@ -132,10 +125,7 @@ func genServer(file *protogen.File, service *protogen.Service, g *protogen.Gener
132
125
g .P ("type " , serverName , " interface {" )
133
126
for _ , method := range service .Methods {
134
127
mop := method .Desc .Options ().(* descriptorpb.MethodOptions )
135
- if mop .GetDeprecated () {
136
- continue
137
- }
138
- if ! proto .HasExtension (mop , pbex .E_Method ) {
128
+ if mop .GetDeprecated () || ! proto .HasExtension (mop , pbex .E_Method ) {
139
129
continue
140
130
}
141
131
emethod := proto .GetExtension (mop , pbex .E_Method ).([]string )
@@ -159,10 +149,7 @@ func genServer(file *protogen.File, service *protogen.Service, g *protogen.Gener
159
149
// Server handler
160
150
for _ , method := range service .Methods {
161
151
mop := method .Desc .Options ().(* descriptorpb.MethodOptions )
162
- if mop .GetDeprecated () {
163
- continue
164
- }
165
- if ! proto .HasExtension (mop , pbex .E_Method ) {
152
+ if mop .GetDeprecated () || ! proto .HasExtension (mop , pbex .E_Method ) {
166
153
continue
167
154
}
168
155
emethod := proto .GetExtension (mop , pbex .E_Method ).([]string )
@@ -745,10 +732,7 @@ func genServer(file *protogen.File, service *protogen.Service, g *protogen.Gener
745
732
g .P ("_=allmids" )
746
733
for _ , method := range service .Methods {
747
734
mop := method .Desc .Options ().(* descriptorpb.MethodOptions )
748
- if mop .GetDeprecated () {
749
- continue
750
- }
751
- if ! proto .HasExtension (mop , pbex .E_Method ) {
735
+ if mop .GetDeprecated () || ! proto .HasExtension (mop , pbex .E_Method ) {
752
736
continue
753
737
}
754
738
emethod := proto .GetExtension (mop , pbex .E_Method ).([]string )
@@ -826,10 +810,7 @@ func genClient(file *protogen.File, service *protogen.Service, g *protogen.Gener
826
810
g .P ("type " , clientName , " interface {" )
827
811
for _ , method := range service .Methods {
828
812
mop := method .Desc .Options ().(* descriptorpb.MethodOptions )
829
- if mop .GetDeprecated () {
830
- continue
831
- }
832
- if ! proto .HasExtension (mop , pbex .E_Method ) {
813
+ if mop .GetDeprecated () || ! proto .HasExtension (mop , pbex .E_Method ) {
833
814
continue
834
815
}
835
816
emethod := proto .GetExtension (mop , pbex .E_Method ).([]string )
@@ -864,10 +845,7 @@ func genClient(file *protogen.File, service *protogen.Service, g *protogen.Gener
864
845
// Client handler
865
846
for _ , method := range service .Methods {
866
847
mop := method .Desc .Options ().(* descriptorpb.MethodOptions )
867
- if mop .GetDeprecated () {
868
- continue
869
- }
870
- if ! proto .HasExtension (mop , pbex .E_Method ) {
848
+ if mop .GetDeprecated () || ! proto .HasExtension (mop , pbex .E_Method ) {
871
849
continue
872
850
}
873
851
emethod := proto .GetExtension (mop , pbex .E_Method ).([]string )
@@ -896,7 +874,7 @@ func genClient(file *protogen.File, service *protogen.Service, g *protogen.Gener
896
874
g .P ("header = make(" , g .QualifiedGoIdent (httpPackage .Ident ("Header" )), ")" )
897
875
g .P ("}" )
898
876
899
- if need == http . MethodGet || need == http . MethodDelete {
877
+ if need == "GET" || need == "DELETE" {
900
878
g .P ("header.Set(" , strconv .Quote ("Content-Type" ), "," , strconv .Quote ("application/x-www-form-urlencoded" ), ")" )
901
879
g .P ("header.Set(" , strconv .Quote ("Accept" ), "," , strconv .Quote ("application/x-protobuf" ), ")" )
902
880
g .P ("query :=" , g .QualifiedGoIdent (poolPackage .Ident ("GetPool" )), "().Get(0)" )
0 commit comments