You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Generally, Gophers tend to code everything into the expected payload, with the expectation that developers are (...hopefully...) smart enough to switch/case on type for the fields they require directly.
As long as you API docs specify this, then it's a case of Read The Manual if they use the SDK wrong.
Having to step through and unmarshal bits of a response manually is much more painful than having all the data there ready to use.
For truly custom user JSON, (for example, user.Data) where you currently have map[string]interface{} you could use json.RawMessage, that way developers themselves can marshal/unmarshal into their required types as needed. Which means the main bit (what FA) cares about is marshalled out into useable data.
(For user data I ended up json.Marshal'ing user.Data to JSON so I could then json.Unmarshal to MyType{} as map[string]interface{} is a pain to work with in terms of complex objects/switch casing/type switch casing and/or marshalling each piece out, I then do the marshal/unmarshal dance in reverse to get me a map[string]interface{} before pushing the data back up 😄 so json.RawMessage would be a win for me here too 👍)
Currently due to the serialization / de-serialization complexity of the IdP APIs, they are omitted from this client.
Here are the APIs we are skipping at the moment:
https://github.com/FusionAuth/fusionauth-client-builder/blob/462c2ca09bb291581164f383428ae276645ace55/src/main/client/go.client.ftl#L186
If we could figure out how to make this work in Go, we would add them.
Here is an example solution provided by @MCBrandenburg https://play.golang.org/p/7ZBAbrDo98w
The text was updated successfully, but these errors were encountered: