@@ -304,7 +304,7 @@ func (tr *Transport) subDirectMethods(ctx context.Context, mux transport.MethodD
304304 tr .logger .Errorf ("dispatch error: %s" , err )
305305 return
306306 }
307- dst := fmt .Sprintf ("$iothub/methods/res/%d/?$rid=%d " , rc , rid )
307+ dst := fmt .Sprintf ("$iothub/methods/res/%d/?$rid=%s " , rc , rid )
308308 if err = tr .send (ctx , dst , DefaultQoS , b ); err != nil {
309309 tr .logger .Errorf ("method response error: %s" , err )
310310 return
@@ -316,31 +316,28 @@ func (tr *Transport) subDirectMethods(ctx context.Context, mux transport.MethodD
316316
317317// returns method name and rid
318318// format: $iothub/methods/POST/{method}/?$rid={rid}
319- func parseDirectMethodTopic (s string ) (string , int , error ) {
319+ func parseDirectMethodTopic (s string ) (string , string , error ) {
320320 const prefix = "$iothub/methods/POST/"
321321
322322 s , err := url .QueryUnescape (s )
323323 if err != nil {
324- return "" , 0 , err
324+ return "" , "" , err
325325 }
326326 u , err := url .Parse (s )
327327 if err != nil {
328- return "" , 0 , err
328+ return "" , "" , err
329329 }
330330
331331 p := strings .TrimRight (u .Path , "/" )
332332 if ! strings .HasPrefix (p , prefix ) {
333- return "" , 0 , errors .New ("malformed direct method topic" )
333+ return "" , "" , errors .New ("malformed direct method topic" )
334334 }
335335
336336 q := u .Query ()
337337 if len (q ["$rid" ]) != 1 {
338- return "" , 0 , errors .New ("$rid is not available" )
339- }
340- rid , err := strconv .Atoi (q ["$rid" ][0 ])
341- if err != nil {
342- return "" , 0 , fmt .Errorf ("$rid parse error: %s" , err )
338+ return "" , "" , errors .New ("$rid is not available" )
343339 }
340+ rid := q ["$rid" ][0 ]
344341 return p [len (prefix ):], rid , nil
345342}
346343
0 commit comments