-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added InitializeObject hook #247
Conversation
Thanks for the PR. Yes what you are saying makes sense. Im just confused that you mentioned I currently don't really understand why go 1.4 fails in travis, but I guess it's some golint issues. I like the interface name, but please squash the |
ok, hm, let's ditch that old version 1.4 then :D |
I would love if you could add a test using the newly introduced behaviour, and additionally shouldn't the interface be something like |
once #248 is merged you can just rebase on it for the tests to work |
👍 just one more rebase before merge |
Thanks! |
Hi there!
First of all thanks for this amazing library!
I'm working on a small very opinionated framework that uses struct tags to simplify the declaration of models. I first thought this might get very complicated with
api2go
as it usesreflect
to create new objects internally. But in fact I learned that most actions go either throughcrud.Find()
orcrud.FindAll()
which allows to setup the object beforejsonapi.Marshal()
orjsonapi.Unmarshal()
is called. The situation that does not allow such access is on a PATCH request. An object gets created withreflect
right before passing it tojsonapi.Unmarshal()
.TL;DR:
This pull request adds an optional method that can be implemented to get access to the dynamically created object in a PATCH request before
jsonapi.Unmarshal()
is called. This is necessary to give context to the models in higher frameworks that abstract thejsonapi
interfaces.Please feel free to change the name of the interface and method. ;)