Skip to content

Commit 7ae31d0

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

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

registry.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,17 @@ 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 before 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
}
2123

2224
interceptors := []Interceptor{}
25+
26+
interceptors = append(interceptors, extra...)
27+
2328
for _, f := range r.factories {
2429
i, err := f.NewInterceptor(id)
2530
if err != nil {

0 commit comments

Comments
 (0)