@@ -147,11 +147,11 @@ func newPathRequest(path string, method string, body string, msg interface{}, ta
147147 switch val .Type ().Kind () {
148148 case reflect .Slice :
149149 for idx := 0 ; idx < val .Len (); idx ++ {
150- values .Add (t .name , fmt . Sprintf ( "%v" , val .Index (idx ). Interface ( )))
150+ values .Add (t .name , getParam ( val .Index (idx )))
151151 }
152152 fieldsmapskip [t .name ] = struct {}{}
153153 default :
154- fieldsmap [t .name ] = fmt . Sprintf ( "%v" , val . Interface () )
154+ fieldsmap [t .name ] = getParam ( val )
155155 }
156156 } else if (body == "*" || body == t .name ) && method != http .MethodGet {
157157 if tnmsg .Field (i ).CanSet () {
@@ -160,10 +160,10 @@ func newPathRequest(path string, method string, body string, msg interface{}, ta
160160 } else {
161161 if val .Type ().Kind () == reflect .Slice {
162162 for idx := 0 ; idx < val .Len (); idx ++ {
163- values .Add (t .name , fmt . Sprintf ( "%v" , val .Index (idx ). Interface ( )))
163+ values .Add (t .name , getParam ( val .Index (idx )))
164164 }
165165 } else {
166- values .Add (t .name , fmt . Sprintf ( "%v" , val . Interface () ))
166+ values .Add (t .name , getParam ( val ))
167167 }
168168 }
169169 }
@@ -216,12 +216,6 @@ func newPathRequest(path string, method string, body string, msg interface{}, ta
216216 _ , _ = b .WriteString (values .Encode ())
217217 }
218218
219- /*
220- if err = rutil.ZeroFieldByPath(nmsg, k); err != nil {
221- return nil, errors.BadRequest("go.micro.client", err.Error())
222- }
223- */
224-
225219 if rutil .IsZero (nmsg ) {
226220 return b .String (), nil , nil
227221 }
@@ -324,3 +318,26 @@ type tag struct {
324318 key string
325319 name string
326320}
321+
322+ func getParam (val reflect.Value ) string {
323+ var v string
324+ switch val .Kind () {
325+ case reflect .Ptr :
326+ switch reflect .Indirect (val ).Type ().String () {
327+ case
328+ "wrapperspb.BoolValue" ,
329+ "wrapperspb.BytesValue" ,
330+ "wrapperspb.DoubleValue" ,
331+ "wrapperspb.FloatValue" ,
332+ "wrapperspb.Int32Value" , "wrapperspb.Int64Value" ,
333+ "wrapperspb.StringValue" ,
334+ "wrapperspb.UInt32Value" , "wrapperspb.UInt64Value" :
335+ if eva := reflect .Indirect (val ).FieldByName ("Value" ); eva .IsValid () {
336+ v = getParam (eva )
337+ }
338+ }
339+ default :
340+ v = fmt .Sprintf ("%v" , val .Interface ())
341+ }
342+ return v
343+ }
0 commit comments