-
Notifications
You must be signed in to change notification settings - Fork 351
/
fail.go
47 lines (34 loc) · 961 Bytes
/
fail.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
"net/http"
"github.com/zalando/skipper/filters"
"github.com/zalando/skipper/routing"
)
// this fails to load, because it implements multiple Init* functions
func InitFilter(opts []string) (filters.Spec, error) {
return noopSpec{}, nil
}
func InitPredicate(opts []string) (routing.PredicateSpec, error) {
return noneSpec{}, nil
}
type noopSpec struct{}
func (s noopSpec) Name() string {
return "noop"
}
func (s noopSpec) CreateFilter(config []interface{}) (filters.Filter, error) {
return noopFilter{}, nil
}
type noopFilter struct{}
func (f noopFilter) Request(filters.FilterContext) {}
func (f noopFilter) Response(filters.FilterContext) {}
type noneSpec struct{}
func (s noneSpec) Name() string {
return "None"
}
func (s noneSpec) Create(config []interface{}) (routing.Predicate, error) {
return nonePredicate{}, nil
}
type nonePredicate struct{}
func (p nonePredicate) Match(*http.Request) bool {
return false
}