and something similar for LasagnaLoveUserContactInfo that contains the plaintext email, addresse(s), phone(s), etc.
Then, in the LasagnaLoveUser struct, you can have fields for LoginDetails, ContactDetails with types *LasagnaLoveUserLogin (notice the *), etc. You can use the omitempty json directive there. That way, if that struct isn't populated at all, it's omitted entirely from the output. And we can still use LasagnaLoveUser across the various APIs... some of the nested structs may just be empty if we don't need that data.
There should be a few separate structs here that compose LasagnaLoveUser I think. Let's think of it in terms of access patterns.
There are a couple:
I'm not a fan of one struct that contains all this stuff directly inside.
So, we can make two additional structs:
and something similar for
LasagnaLoveUserContactInfo
that contains the plaintext email, addresse(s), phone(s), etc.Then, in the
LasagnaLoveUser
struct, you can have fields forLoginDetails
,ContactDetails
with types*LasagnaLoveUserLogin
(notice the*
), etc. You can use theomitempty
json directive there. That way, if that struct isn't populated at all, it's omitted entirely from the output. And we can still useLasagnaLoveUser
across the various APIs... some of the nested structs may just be empty if we don't need that data._Originally posted by @iamthebot in https://github.com/Lasagna-Love-Portal/bechamel-api/pull/1#discussion_r1185728788_