func serviceList(w http.ResponseWriter, r *http.Request, t auth.Token) error {
	contexts := permission.ContextsForPermission(t, permission.PermServiceRead)
	services, err := provisionReadableServices(t, contexts)
	if err != nil {
		return err
	}
	sInstances, err := service.GetServiceInstancesByServices(services)
	if err != nil {
		return err
	}
	results := make([]service.ServiceModel, len(services))
	for i, s := range services {
		results[i].Service = s.Name
		for _, si := range sInstances {
			if si.ServiceName == s.Name {
				results[i].Instances = append(results[i].Instances, si.Name)
				results[i].ServiceInstances = append(results[i].ServiceInstances, si)
			}
		}
	}
	if len(results) == 0 {
		w.WriteHeader(http.StatusNoContent)
		return nil
	}
	w.Header().Set("Content-Type", "application/json")
	return json.NewEncoder(w).Encode(results)
}
func serviceList(w http.ResponseWriter, r *http.Request, t auth.Token) error {
	contexts := permission.ContextsForPermission(t, permission.PermServiceRead)
	services, err := provisionReadableServices(t, contexts)
	if err != nil {
		return err
	}
	sInstances, err := service.GetServiceInstancesByServices(services)
	if err != nil {
		return err
	}
	results := make([]service.ServiceModel, len(services))
	for i, s := range services {
		results[i].Service = s.Name
		for _, si := range sInstances {
			if si.ServiceName == s.Name {
				results[i].Instances = append(results[i].Instances, si.Name)
				results[i].ServiceInstances = append(results[i].ServiceInstances, si)
			}
		}
	}
	if len(results) == 0 {
		w.WriteHeader(http.StatusNoContent)
		return nil
	}
	w.Header().Set("Content-Type", "application/json")
	return json.NewEncoder(w).Encode(results)
}
func serviceList ( w http . ResponseWriter , r * http . Request , t auth . Token ) error { contexts := permission . ContextsForPermission ( t , permission . PermServiceRead ) services , err := provisionReadableServices ( t , contexts ) if err != nil { return err } sInstances , err := service . GetServiceInstancesByServices ( services ) if err != nil { return err } results := make ( [ ] service . ServiceModel , len ( services ) ) for i , s := range services { results [ i ] . Service = s . Name for _ , si := range sInstances { if si . ServiceName == s . Name { results [ i ] . Instances = append ( results [ i ] . Instances , si . Name ) results [ i ] . ServiceInstances = append ( results [ i ] . ServiceInstances , si ) } } } if len ( results ) == 0 { w . WriteHeader ( http . StatusNoContent ) return nil } w . Header ( ) . Set ( " " , " " ) return json . NewEncoder ( w ) . Encode ( results ) }
// title: service list
// path: /services
// method: GET
// produce: application/json
// responses:
//   200: List services
//   204: No content
//   401: Unauthorized
title : service list path : / services method : GET produce : application / json responses : 200 : List services 204 : No content 401 : Unauthorized