Пример #1
0
func ListServices(reg registry.Registry) string {
	services, err := reg.ListServices()
	if err != nil {
		return err.Error()
	}
	jsonRes, _ := json.Marshal(services)
	return string(jsonRes)
}
Пример #2
0
func ListServiceProviders(params martini.Params, reg registry.Registry) string {
	serviceName := params["name"]
	providers, err := reg.ListServiceProviders(serviceName)
	if err != nil {
		return err.Error()
	}
	jsonRes, _ := json.Marshal(providers)
	return string(jsonRes)
}
Пример #3
0
func UpdateServiceProvider(req *http.Request, params martini.Params, reg registry.Registry) string {
	body, _ := ioutil.ReadAll(req.Body)
	defer req.Body.Close()

	providerInfo := registry.ProviderInfo{}
	err := json.Unmarshal(body, &providerInfo)
	if err != nil {
		return err.Error()
	}

	serviceName := params["name"]

	err = reg.UpdateServiceProvider(serviceName, providerInfo)
	if err != nil {
		return err.Error()
	}
	return "{\"ok\"}"
}