func listUnitsByApp(w http.ResponseWriter, r *http.Request, t auth.Token) error {
	appName := r.URL.Query().Get(":appname")
	a, err := app.GetByName(appName)
	if err != nil {
		if err == appTypes.ErrAppNotFound {
			return &tsuruErrors.HTTP{
				Code:    http.StatusNotFound,
				Message: err.Error(),
			}
		}
		return err
	}
	canRead := permission.Check(t, permission.PermAppRead,
		contextsForApp(a)...,
	)
	if !canRead {
		return permission.ErrUnauthorized
	}
	units, err := a.Units()
	if err != nil {
		return err
	}
	if len(units) == 0 {
		w.WriteHeader(http.StatusNoContent)
		return nil
	}
	w.Header().Set("Content-Type", "application/json")
	return json.NewEncoder(w).Encode(units)
}
func listUnitsByApp(w http.ResponseWriter, r *http.Request, t auth.Token) error {
	appName := r.URL.Query().Get(":appname")
	a, err := app.GetByName(appName)
	if err != nil {
		if err == appTypes.ErrAppNotFound {
			return &tsuruErrors.HTTP{
				Code:    http.StatusNotFound,
				Message: err.Error(),
			}
		}
		return err
	}
	canRead := permission.Check(t, permission.PermAppRead,
		contextsForApp(a)...,
	)
	if !canRead {
		return permission.ErrUnauthorized
	}
	units, err := a.Units()
	if err != nil {
		return err
	}
	if len(units) == 0 {
		w.WriteHeader(http.StatusNoContent)
		return nil
	}
	w.Header().Set("Content-Type", "application/json")
	return json.NewEncoder(w).Encode(units)
}
func listUnitsByApp ( w http . ResponseWriter , r * http . Request , t auth . Token ) error { appName := r . URL . Query ( ) . Get ( " " ) a , err := app . GetByName ( appName ) if err != nil { if err == appTypes . ErrAppNotFound { return & tsuruErrors . HTTP { Code : http . StatusNotFound , Message : err . Error ( ) , } } return err } canRead := permission . Check ( t , permission . PermAppRead , contextsForApp ( a ) ... , ) if ! canRead { return permission . ErrUnauthorized } units , err := a . Units ( ) if err != nil { return err } if len ( units ) == 0 { w . WriteHeader ( http . StatusNoContent ) return nil } w . Header ( ) . Set ( " " , " " ) return json . NewEncoder ( w ) . Encode ( units ) }
// title: list units by app
// path: /docker/node/apps/{appname}/containers
// method: GET
// produce: application/json
// responses:
//   200: Ok
//   204: No content
//   401: Unauthorized
//   404: Not found
title : list units by app path : / docker / node / apps / { appname } / containers method : GET produce : application / json responses : 200 : Ok 204 : No content 401 : Unauthorized 404 : Not found