Skip to content

Commit

Permalink
Make Registry.Build take extra interceptors
Browse files Browse the repository at this point in the history
Make Registry.Build take an optional list of extra interceptors
that are added after the ones specified by the registry.
  • Loading branch information
jech committed Jan 13, 2025
1 parent 82bca40 commit 1a82ea1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ func (r *Registry) Add(f Factory) {
}

// Build constructs a single Interceptor from a InterceptorRegistry
func (r *Registry) Build(id string) (Interceptor, error) {
// The extra interceptors are added to the chain after the ones specified
// by the registry.
func (r *Registry) Build(id string, extra... Interceptor) (Interceptor, error) {

Check warning on line 19 in registry.go

View check run for this annotation

Codecov / codecov/patch

registry.go#L19

Added line #L19 was not covered by tests
if len(r.factories) == 0 {
return &NoOp{}, nil
}
Expand All @@ -29,5 +31,7 @@ func (r *Registry) Build(id string) (Interceptor, error) {
interceptors = append(interceptors, i)
}

interceptors = append(interceptors, extra...)

Check warning on line 35 in registry.go

View check run for this annotation

Codecov / codecov/patch

registry.go#L34-L35

Added lines #L34 - L35 were not covered by tests
return NewChain(interceptors), nil
}

0 comments on commit 1a82ea1

Please sign in to comment.