Exemple #1
0
//GetDefinitionList returns a list of route definitions
func (RouteDef) GetDefinitionList(kvs kvstore.KVStore, resp http.ResponseWriter, req *http.Request) (interface{}, error) {
	log.Info("route GetDefinitionList service called")
	routes, err := config.ListRouteConfigs(kvs)
	if err != nil {
		resp.WriteHeader(http.StatusInternalServerError)
		return nil, err
	}

	if routes == nil {
		routes = make([]*config.RouteConfig, 0)
	}

	return routes, nil

}
Exemple #2
0
//Run executes the RouteList command with the supplied args
func (sl *RouteList) Run(args []string) int {
	routes, err := config.ListRouteConfigs(sl.KVStore)
	if err != nil {
		sl.UI.Error(err.Error())
		return 1
	}

	jsonRep, err := json.Marshal(routes)
	if err != nil {
		sl.UI.Error(err.Error())
		return 1
	}

	if bytes.Equal(jsonRep, config.NullJSON) {
		sl.UI.Output("[]")
	} else {
		sl.UI.Output(string(jsonRep))
	}

	return 0
}