Skip to content

Conversation

@boblail
Copy link
Contributor

@boblail boblail commented Mar 20, 2025

Lets you pass kong.WithBeforeApply along with a function that supports dynamic bindings to register a BeforeApply hook without tying it directly to a node in the schema.

Also updates the README.md to list a table of hooks with their meanings.

options.go Outdated
})
}

func BeforeApplyHook(fn hook) Option {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was literally just wanting this functionality yesterday, so +1 from me.

I'd prefer this to be named WithBeforeApply, and fn will have to be any to correctly match any function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

What do you think of removing https://github.com/alecthomas/kong/blob/master/hooks.go and naming these functional options BeforeReset, BeforeResolve, etc?

@boblail boblail force-pushed the lail/register-hooks-via-Options branch from 11f88bf to ccac06b Compare March 21, 2025 22:26
@boblail boblail marked this pull request as ready for review March 21, 2025 22:27
Lets you pass `kong.WithBeforeApply` along with a function that supports dynamic bindings to register a `BeforeApply` hook without tying it directly to a node in the schema.

Co-authored-by: Sutina Wipawiwat <[email protected]>
@boblail boblail force-pushed the lail/register-hooks-via-Options branch from ccac06b to afbf0c1 Compare March 21, 2025 22:32
@boblail boblail requested a review from alecthomas March 21, 2025 22:33
Copy link
Owner

@alecthomas alecthomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks!

@alecthomas alecthomas merged commit 78d4066 into alecthomas:master Mar 22, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants