jcelliott / turnpike

Go implementation of a WAMP (Web Application Messaging Protocol) client and router
MIT License
258 stars 88 forks source link

Add 'omitempty' to args and kwargs #44

Closed jcelliott closed 10 years ago

jcelliott commented 10 years ago

https://github.com/tavendo/WAMP/blob/master/spec/basic.md#empty-arguments-and-keyword-arguments

beatgammit commented 10 years ago

Perhaps optional fields can have a wamp tag:

type Call struct {
    Request ID
    Options map[string]interface{}
    Procedure URI
    Arguments []interface{} `wamp:"omitempty"`
    ArgumentsKw map[string]interface{} `wamp:"omitempty"`
}

Fields will be traversed backwards looking for omitempty, and those that are nil or 0-length are omitted.