divan / gorilla-xmlrpc

Gorilla XML RPC implementation (Golang/Go)
BSD 3-Clause "New" or "Revised" License
69 stars 59 forks source link

Allow overriding struct member name for XML-RPC request/response? #15

Closed daluu closed 7 years ago

daluu commented 7 years ago

Say I had a struct like this:

type runKeywordReturnType struct{
  sReturn interface{}
  status string
  output string
  sError string
  traceback string
}

but that I really wanted sReturn & sError to be all lowercase w/o the prefix "s", at least when served back as XML-RPC response (from server), is there a way to do that to map some stuff from native go to XML-RPC response?

There is such an option for XML-RPC.NET (.NET library): http://xml-rpc.net/faq/xmlrpcnetfaq-2-5-0.html#1.11

where I did something similar to

[XmlRpcMember("return")] 
public int Return; 

Might something like that be available in this package or the core gorilla/rpc one? Or in native go?

Well, I've seen something like that for JSON marshalling/unmarshalling in go, e.g.:

type Coordinate struct {
    X         float64 `json:"x"`
    Y         float64 `json:"y"`
}

where in go it's in one casing for example, yet another in raw JSON. Is there similar mapping usable for this XML-RPC? Where in go native struct, it's one way, and in a different case when served back as XML-RPC output?

daluu commented 7 years ago

Nevermind, I figured it out learning about struct tags, particular to encoding/xml, and looking through this code.

As a result created PR #17 as well.