mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-15 12:27:59 +08:00
32 lines
690 B
Go
32 lines
690 B
Go
package option
|
|
|
|
// HookOptions contains options for action hooks
|
|
type HookOptions struct {
|
|
// pre hook before action
|
|
PreHook func()
|
|
// post hook after action
|
|
PostHook func()
|
|
}
|
|
|
|
// WithPreHook sets the pre hook before action
|
|
func WithPreHook(preHook func()) ActionOption {
|
|
return func(o *ActionOptions) {
|
|
o.PreHook = preHook
|
|
}
|
|
}
|
|
|
|
// WithPostHook sets the post hook after action
|
|
func WithPostHook(postHook func()) ActionOption {
|
|
return func(o *ActionOptions) {
|
|
o.PostHook = postHook
|
|
}
|
|
}
|
|
|
|
// WithHooks sets the pre hook and post hook
|
|
func WithHooks(preHook func(), postHook func()) ActionOption {
|
|
return func(o *ActionOptions) {
|
|
o.PreHook = preHook
|
|
o.PostHook = postHook
|
|
}
|
|
}
|