Update endpoints.WrapAll to panic if excluded endpoint does not exist

This commit is contained in:
Adam Ryman 2017-03-28 14:57:57 -07:00
Родитель 852beea59e
Коммит a07dda320c
2 изменённых файлов: 7 добавлений и 4 удалений

Просмотреть файл

@ -6,6 +6,7 @@ package svc
// formats. It also includes endpoint middlewares.
import (
"fmt"
"golang.org/x/net/context"
"github.com/go-kit/kit/endpoint"
@ -25,8 +26,7 @@ import (
//
// In a client, it's useful to collect individually constructed endpoints into a
// single type that implements the Service interface. For example, you might
// construct individual endpoints using transport/http.NewClient, combine them
// into an Endpoints, and return it to the caller as a Service.
// construct individual endpoints using transport/http.NewClient, combine them into an Endpoints, and return it to the caller as a Service.
type Endpoints struct {
{{range $i := .Service.Methods}}
{{$i.Name}}Endpoint endpoint.Endpoint
@ -73,6 +73,9 @@ func (e *Endpoints) WrapAll(middleware endpoint.Middleware, excluded ...string)
}
for _, ex := range excluded {
if _, ok := included[ex]; !ok {
panic(fmt.Sprintf("Excluded endpoint '%s' does not exist; see middlewares/endpoints.go", ex))
}
delete(included, ex)
}

Различия файлов скрыты, потому что одна или несколько строк слишком длинны