MCPcopy Index your code
hub / github.com/zalando/skipper / Example

Function Example

filters/example_test.go:54–89  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

52func (f *customFilter) Response(_ filters.FilterContext) {}
53
54func Example() {
55 // create registry
56 registry := builtin.MakeRegistry()
57
58 // create and register the filter specification
59 spec := &customSpec{name: "customFilter"}
60 registry.Register(spec)
61
62 // create simple data client, with route entries referencing 'customFilter',
63 // and clipping part of the request path:
64 dataClient, err := testdataclient.NewDoc(`
65
66 ui: Path("/ui/*page") ->
67 customFilter("ui request") ->
68 modPath("^/[^/]*", "") ->
69 "https://ui.example.org";
70
71 api: Path("/api/*resource") ->
72 customFilter("api request") ->
73 modPath("^/[^/]*", "") ->
74 "https://api.example.org"`)
75
76 if err != nil {
77 log.Fatal(err)
78 }
79
80 // create routing object:
81 rt := routing.New(routing.Options{
82 FilterRegistry: registry,
83 DataClients: []routing.DataClient{dataClient}})
84 defer rt.Close()
85
86 // create http.Handler:
87 p := proxy.New(rt, proxy.OptionsNone)
88 defer p.Close()
89}

Callers

nothing calls this directly

Calls 6

MakeRegistryFunction · 0.92
NewDocFunction · 0.92
NewFunction · 0.92
NewFunction · 0.92
RegisterMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…