Skip to content

Commit 1a82ea1

Browse files
committed
Make Registry.Build take extra interceptors
Make Registry.Build take an optional list of extra interceptors that are added after the ones specified by the registry.
1 parent 82bca40 commit 1a82ea1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

registry.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ func (r *Registry) Add(f Factory) {
1414
}
1515

1616
// Build constructs a single Interceptor from a InterceptorRegistry
17-
func (r *Registry) Build(id string) (Interceptor, error) {
17+
// The extra interceptors are added to the chain after the ones specified
18+
// by the registry.
19+
func (r *Registry) Build(id string, extra... Interceptor) (Interceptor, error) {
1820
if len(r.factories) == 0 {
1921
return &NoOp{}, nil
2022
}
@@ -29,5 +31,7 @@ func (r *Registry) Build(id string) (Interceptor, error) {
2931
interceptors = append(interceptors, i)
3032
}
3133

34+
interceptors = append(interceptors, extra...)
35+
3236
return NewChain(interceptors), nil
3337
}

0 commit comments

Comments
 (0)