go-zero icon indicating copy to clipboard operation
go-zero copied to clipboard

Does go-zero have a package implementation of the hook function?

Open ShyunnY opened this issue 2 years ago • 6 comments
trafficstars

ShyunnY avatar Jan 21 '23 07:01 ShyunnY

For what kind of hook?

kevwan avatar Jan 21 '23 09:01 kevwan

I would like to add the execution function either before or after the execution business function, if this package is not currently available, I can submit a pr in the util package and let you see if it fits. Thank you for your reply on New Year's Eve and I wish you a happy new year.

ShyunnY avatar Jan 21 '23 12:01 ShyunnY

You can use middleware to achieve this.

kevwan avatar Jan 21 '23 13:01 kevwan

Middleware acts before and after logic, but I don't really want that. Because I have the flexibility to add hooks to other functions when I call them from within the logic

ShyunnY avatar Jan 21 '23 13:01 ShyunnY

You can wrap the func with a closure.

kevwan avatar Jan 21 '23 13:01 kevwan

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Jan 22 '24 01:01 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar Apr 24 '24 01:04 github-actions[bot]