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
feat: Allow configuring global hooks via Kong's functional options (#511)
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]>
|`BeforeReset`| Invoked before values are reset to their defaults (as defined by the grammar) or to zero values |
318
+
|`BeforeResolve`| Invoked before resolvers are applied to a node |
319
+
|`BeforeApply`| Invoked before the traced command line arguments are applied to the grammar |
320
+
|`AfterApply`| Invoked after command line arguments are applied to the grammar **and validated**` |
315
321
316
322
The `--help` flag is implemented with a `BeforeReset` hook.
317
323
@@ -340,6 +346,10 @@ func main() {
340
346
}
341
347
```
342
348
349
+
It's also possible to register these hooks with the functional options
350
+
`kong.WithBeforeReset`, `kong.WithBeforeResolve`, `kong.WithBeforeApply`, and
351
+
`kong.WithAfterApply`.
352
+
343
353
## The Bind() option
344
354
345
355
Arguments to hooks are provided via the `Run(...)` method or `Bind(...)` option. `*Kong`, `*Context`, `*Path` and parent commands are also bound and finally, hooks can also contribute bindings via `kong.Context.Bind()` and `kong.Context.BindTo()`.
0 commit comments