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
I need to be able to have some predefined values injected to the prototype passed to the AddResource function and was thinking of opening a pull request for something like this, but before even starting that work I'd like to hear your opinion on this functionality and behaviour. As the internal addResource uses reflection to create the resource from the prototype I cannot prepopulate anything while calling the AddResource funtion itself.
For backwards compatibility I'd be adding a separate function for this, such as:
// The original AddResource:func (api*API) AddResource(prototype jsonapi.MarshalIdentifier, sourceinterface{}) {
api.addResource(prototype, source)
}
// the interface that creates the resourcetypeResourceCreatorinterface {
CreateResourcePrototype() jsonapi.MarshalIdentifier
}
// Actual method; the name TBDfunc (api*API) AddResourceCreator(creatorResourceCreator, sourceinterface{}) {
...
}
So it would be used along the lines of this (crappy example but hopefully illustrates the purpose):
typeMyThingstruct {
PathFormatstring
}
typeMyCreatorstruct {
// The PathFormat used as an example could be specified here along with other whatever dependencies
}
func (mMyCreator) CreateResourcePrototype() jsonapi.MarshalIdentifier {
// this way whatever configuration can be placed to the creator itself and it injects it to the prototype:returnMyThing {
PathFormat: "/product/{productId}/{slug}",
}
}
Does this make sense?
The text was updated successfully, but these errors were encountered:
I need to be able to have some predefined values injected to the prototype passed to the
AddResource
function and was thinking of opening a pull request for something like this, but before even starting that work I'd like to hear your opinion on this functionality and behaviour. As the internal addResource uses reflection to create the resource from the prototype I cannot prepopulate anything while calling theAddResource
funtion itself.For backwards compatibility I'd be adding a separate function for this, such as:
original function at https://github.com/manyminds/api2go/blob/master/api_public.go#L45
So it would be used along the lines of this (crappy example but hopefully illustrates the purpose):
Does this make sense?
The text was updated successfully, but these errors were encountered: