示例#1
0
func Register(client routing_api.Client, tokenFetcher token_fetcher.TokenFetcher, routes []db.Route) error {
	token, err := tokenFetcher.FetchToken()
	if err != nil {
		return err
	}
	client.SetToken(token.AccessToken)
	return client.UpsertRoutes(routes)
}
示例#2
0
func List(client routing_api.Client, tokenFetcher token_fetcher.TokenFetcher) ([]db.Route, error) {
	token, err := tokenFetcher.FetchToken()
	if err != nil {
		return nil, err
	}
	client.SetToken(token.AccessToken)
	return client.Routes()
}
示例#3
0
func Events(client routing_api.Client, tokenFetcher token_fetcher.TokenFetcher) (routing_api.EventSource, error) {
	token, err := tokenFetcher.FetchToken()
	if err != nil {
		return nil, err
	}
	client.SetToken(token.AccessToken)
	return client.SubscribeToEvents()
}