Skip to content

Commit

Permalink
Moved general error instance to the filters package to be reused
Browse files Browse the repository at this point in the history
Closes #18
  • Loading branch information
lmineiro committed Oct 16, 2015
1 parent f9a4095 commit 7136091
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
5 changes: 5 additions & 0 deletions filters/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package filters
import (
// import filter packages here:

"errors"
"github.com/zalando/skipper/filters/healthcheck"
"github.com/zalando/skipper/filters/humanstxt"
"github.com/zalando/skipper/filters/pathrewrite"
Expand All @@ -14,6 +15,10 @@ import (
"github.com/zalando/skipper/skipper"
)

var (
ErrInvalidFilterParameters = errors.New("Invalid filter parameters")
)

// takes a registry object and registers the filter spec in the package
func Register(registry skipper.FilterRegistry) {
registry.Add(
Expand Down
10 changes: 3 additions & 7 deletions filters/flowid/filter.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package flowid

import (
"errors"
"github.com/zalando/skipper/filters"
"github.com/zalando/skipper/skipper"
)

Expand All @@ -16,10 +16,6 @@ type flowId struct {
flowIdLength uint8
}

var (
ErrInvalidFilterParameters = errors.New("Invalid filter parameters")
)

func New(id string, allowOverride bool, len uint8) skipper.Filter {
return &flowId{id, allowOverride, len}
}
Expand Down Expand Up @@ -53,15 +49,15 @@ func (this *flowId) MakeFilter(id string, fc skipper.FilterConfig) (skipper.Filt
if r, ok := fc[0].(bool); ok {
reuseExisting = r
} else {
return nil, ErrInvalidFilterParameters
return nil, filters.ErrInvalidFilterParameters
}
}
var flowIdLength uint8 = defaultLen
if len(fc) > 1 {
if l, ok := fc[1].(float64); ok && l >= minLength && l <= maxLength {
flowIdLength = uint8(l)
} else {
return nil, ErrInvalidFilterParameters
return nil, filters.ErrInvalidFilterParameters
}
}
return New(id, reuseExisting, flowIdLength), nil
Expand Down

0 comments on commit 7136091

Please sign in to comment.