func createReadClient(m *medium) (readClient, error) { // no output, no client if m == nil { return nil, nil } switch m.typ { case innkeeper: return createInnkeeperClient(m) case etcd: return etcdclient.New(etcdclient.Options{ Endpoints: urlsToStrings(m.urls), Prefix: m.path, Insecure: insecure}) case stdin: return &stdinReader{reader: os.Stdin}, nil case file: return eskipfile.Open(m.path) case inline: return &inlineReader{routes: m.eskip}, nil case inlineIds: return &idsReader{ids: m.ids}, nil default: return nil, invalidInputType } }
func createDataClients(o Options, auth innkeeper.Authentication) ([]routing.DataClient, error) { var clients []routing.DataClient if o.RoutesFile != "" { f, err := eskipfile.Open(o.RoutesFile) if err != nil { return nil, err } clients = append(clients, f) } if o.InnkeeperUrl != "" { ic, err := innkeeper.New(innkeeper.Options{ o.InnkeeperUrl, o.ProxyOptions.Insecure(), auth, o.InnkeeperPreRouteFilters, o.InnkeeperPostRouteFilters}) if err != nil { return nil, err } clients = append(clients, ic) } if len(o.EtcdUrls) > 0 { clients = append(clients, etcd.New(o.EtcdUrls, o.EtcdPrefix)) } return clients, nil }
// load and parse routes from a file using the eskipfile client. func loadFile(path string) (loadResult, error) { client, err := eskipfile.Open(path) if err != nil { return loadResult{}, err } routes, err := client.LoadAll() return loadResult{routes: routes}, err }
func Example() { // open file with a routing table: dataClient, err := eskipfile.Open("/some/path/to/routing-table.eskip") if err != nil { // log.Fatal(err) return } // create http.Handler: proxy.New( routing.New(routing.Options{ DataClients: []routing.DataClient{dataClient}}), proxy.OptionsNone) }
func createDataClients(o Options, auth innkeeper.Authentication) ([]routing.DataClient, error) { var clients []routing.DataClient if o.RoutesFile != "" { f, err := eskipfile.Open(o.RoutesFile) if err != nil { log.Error(err) return nil, err } clients = append(clients, f) } if o.InnkeeperUrl != "" { ic, err := innkeeper.New(innkeeper.Options{ o.InnkeeperUrl, o.InnkeeperInsecure, auth, o.InnkeeperPreRouteFilters, o.InnkeeperPostRouteFilters}) if err != nil { log.Error(err) return nil, err } clients = append(clients, ic) } if len(o.EtcdUrls) > 0 { etcdClient, err := etcd.New(etcd.Options{ o.EtcdUrls, o.EtcdPrefix, o.EtcdWaitTimeout, o.EtcdInsecure}) if err != nil { return nil, err } clients = append(clients, etcdClient) } if o.KubernetesURL != "" { clients = append(clients, kubernetes.New(kubernetes.Options{ KubernetesURL: o.KubernetesURL, ProvideHealthcheck: o.KubernetesHealthcheck, })) } return clients, nil }