Closed jakdept closed 4 years ago
What's the exact use-case here? Maybe I'm just lucky, but I've never seen a xmlrpc endpoint with optional parameters.
You hit it exactly on the head - I'm working against an API that has optional parameters for some calls.
In this case, the methodRoute
is always the same, the first param
is always an authentication object, the second and third param
are actually the routing keys, and the fourth param is the data - sometimes a struct, sometimes a single non-optional value.
Specifying the value in the request as 0 if an integer, or a empty string if a string, is obviously different than not specifying it.
@jakdept thanks for the contribution.
I've modified the encoder to honor a tag of:
This allows someone to skip sending values that are empty - as defined by
reflect.Value.IsZero()
.Note, this may be a breaking change? If anyone has a struct with a tag of
something,omitempty
this will also strip,omitempty
from the end of that tag and possibly not send it? I would expect this would be unintended behavior?I also added a test to explicitly show what happens when you encode a empty struct:
I don't know if that's intended, and I didn't see anything in the XMLRPC spec about an empty
<struct>
element, so I don't know if that's right?