Esempio n. 1
0
//GetDefinitionList returns a list of listener definitions
func (ListenerDef) GetDefinitionList(kvs kvstore.KVStore, resp http.ResponseWriter, req *http.Request) (interface{}, error) {
	log.Info("listener GetDefinitionList service called")
	listeners, err := config.ListListenerConfigs(kvs)
	if err != nil {
		resp.WriteHeader(http.StatusInternalServerError)
		return nil, err
	}

	if listeners == nil {
		listeners = make([]*config.ListenerConfig, 0)
	}

	return listeners, nil

}
Esempio n. 2
0
//Run executes the ListenerList command with the supplied args
func (sl *ListenerList) Run(args []string) int {
	listeners, err := config.ListListenerConfigs(sl.KVStore)
	if err != nil {
		sl.UI.Error(err.Error())
		return 1
	}

	jsonRep, err := json.Marshal(listeners)
	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
}