Skip to content

Commit

Permalink
Utility for testing your middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
Nate North committed Jun 2, 2024
1 parent 54201dc commit cb68963
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions buzz.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,12 @@ func (chain *CallChain) Next(ctx context.Context) error {

// MiddleFunc defines the type of any middleware that can be used in the hive.
type MiddleFunc func(ctx context.Context, chain *CallChain) error

// NewTestCallChain creates a new [CallChain] that simply executes the given [MiddleFunc].
// The provided [MiddleFunc] will recieve a nil [CallChain]. This function is a utility to
// make it easy to test your own middleware.
func NewTestCallChain(exec MiddleFunc) *CallChain {
return &CallChain{
exec: exec,
}
}

0 comments on commit cb68963

Please sign in to comment.