// AppGroupsMatches handles GET /apps-groups/matches api endpoint. Finds possible matches for the group. Only available on mongo
AppGroupsMatches handles GET /apps-groups/matches api endpoint. Finds possible matches for the group. Only available on mongo
// AppGroupsMatches handles GET / apps - groups / matches api endpoint . Finds possible matches for the group . Only available on mongo
func AppGroupsMatches(c *routing.Context) error {
	groupName := string(c.QueryArgs().Peek("group_name"))
	if groupName == "" {
		http.Response(c, `{"error":true, "msg": "Invalid group name"}`, 400, ServiceDiscoveryServiceName(), config.APPLICATION_JSON)
		return nil
	}
	session, db := database.GetSessionAndDB(database.MONGO_DB)
	var servicesThatMatch []service.Service
	query := []bson.M{
		{"$lookup": bson.M{"from": constants.SERVICE_APPS_GROUP_COLLECTION, "localField": "_id", "foreignField": "services", "as": "service_app_group"}},
		{"$addFields": bson.M{"zeroAppGroups": bson.M{"$not": bson.M{"$size": "$service_app_group"}}}},
		{"$match": bson.M{"zeroAppGroups": true, "matchinguri": bson.RegEx{"/api/(experience|system|process)/(v1/)?" + groupName + "(/\\w*)?", "i"}}},
	}
	db.C(constants.SERVICES_COLLECTION).Pipe(query).All(&servicesThatMatch)
	database.MongoDBPool.Close(session)
	if len(servicesThatMatch) == 0 {
		http.Response(c, `[]`, 200, ServiceDiscoveryServiceName(), config.APPLICATION_JSON)
		return nil
	}
	servicesThatMatchJSON, _ := json.Marshal(servicesThatMatch)
	return http.Ok(c, string(servicesThatMatchJSON), ServiceDiscoveryServiceName())
}
func AppGroupsMatches ( c * routing . Context ) error { groupName := string ( c . QueryArgs ( ) . Peek ( " " ) ) if groupName == " " { http . Response ( c , `{"error":true, "msg": "Invalid group name"}` , 400 , ServiceDiscoveryServiceName ( ) , config . APPLICATION_JSON ) return nil } session , db := database . GetSessionAndDB ( database . MONGO_DB ) var servicesThatMatch [ ] service . Service query := [ ] bson . M { { " " : bson . M { " " : constants . SERVICE_APPS_GROUP_COLLECTION , " " : " " , " " : " " , " " : " " } } , { " " : bson . M { " " : bson . M { " " : bson . M { " " : " " } } } } , { " " : bson . M { " " : true , " " : bson . RegEx { " " + groupName + " \\ " , " " } } } , } db . C ( constants . SERVICES_COLLECTION ) . Pipe ( query ) . All ( & servicesThatMatch ) database . MongoDBPool . Close ( session ) if len ( servicesThatMatch ) == 0 { http . Response ( c , `[]` , 200 , ServiceDiscoveryServiceName ( ) , config . APPLICATION_JSON ) return nil } servicesThatMatchJSON , _ := json . Marshal ( servicesThatMatch ) return http . Ok ( c , string ( servicesThatMatchJSON ) , ServiceDiscoveryServiceName ( ) ) }
AppGroupsMatches handles GET /apps-groups/matches api endpoint.
AppGroupsMatches handles GET / apps - groups / matches api endpoint .
// query := bson.M{"matchinguri": bson.RegEx{"/api/(experience|system|process)/" + groupName + "/\\w+", ""}}