-
Notifications
You must be signed in to change notification settings - Fork 111
Open
Labels
proposalA suggestion for change that has not been acceptedA suggestion for change that has not been accepted
Description
Hooks have several problems and limitations compared to middleware:
- We need two methods (before and after hooks)
- We can't control the flow as detailed as we would want (Find hooks can modify the query, Get hooks can't)
- We can't abort/change the flow without raising an error (E.g. call patch instead of delete/clear to implement soft delete).
With middleware we get more power:
- We can do both pre and post operations within a single method.
- We can control the flow, e.g. call patch instead of delete to implement soft delete.
- We can always modify the query.
I want to suggest completely removing resource hooks in favor of middleware. This may involve making resource.Resource
an interface that can be wrapped, or we might decide it's sufficient to wrap the storage layer and document that as the way to implement hooks. It could also involve changing the methods of a resource to be settable (except for wrapper methods such as MultiGet), setting the methods to the storage layer method on initalization, and wrapping them when Resource.Use is called.
Metadata
Metadata
Assignees
Labels
proposalA suggestion for change that has not been acceptedA suggestion for change that has not been accepted