forked from zalando/skipper
/
string.go
36 lines (30 loc) · 834 Bytes
/
string.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
// Package routestring provides a DataClient implementation for
// setting route configuration in form of simple eskip string.
//
// Usage from the command line:
//
// skipper -inline-routes '* -> inlineContent("Hello, world!") -> <shunt>'
//
package routestring
import (
"github.com/zalando/skipper/eskip"
"github.com/zalando/skipper/routing"
)
type routes struct {
parsed []*eskip.Route
}
// New creates a data client that parses a string of eskip routes and
// serves it for the routing package.
func New(r string) (routing.DataClient, error) {
parsed, err := eskip.Parse(r)
if err != nil {
return nil, err
}
return &routes{parsed: parsed}, nil
}
func (r *routes) LoadAll() ([]*eskip.Route, error) {
return r.parsed, nil
}
func (*routes) LoadUpdate() ([]*eskip.Route, []string, error) {
return nil, nil, nil
}