func DeassociateServiceFromGroup(c *routing.Context) error {
	serviceGroupID := c.Param("group_id")
	serviceID := c.Param("service_id")
	if serviceGroupID == "null" || serviceID == "null" || serviceID == "" {
		http.Response(c, `{"error": "Invalid body."}`, 400, ServiceDiscoveryServiceName(), config.APPLICATION_JSON)
		return nil
	}
	serviceGroupService, _ := getServiceGroupsService(c)
	err := serviceGroupService.RemoveServiceFromGroup(serviceGroupID, serviceID)
	if err != nil {
		return http.Error(c, strconv.Quote(err.Error()), 400, ServiceDiscoveryServiceName())
	}
	return http.Created(c, "Service deassociated from group successfuly", ServiceDiscoveryServiceName())
}
DeassociateServiceFromGroup handle DELETE /
package controllers
import (
	"encoding/json"
	"strconv"
	"github.com/Glintt/gAPI/api/config"
	"github.com/Glintt/gAPI/api/http"
	"github.com/Glintt/gAPI/api/servicediscovery"
	"github.com/Glintt/gAPI/api/servicediscovery/servicegroup"
	routing "github.com/qiangxue/fasthttp-routing"
)
func getServiceGroupsService(c *routing.Context) (servicegroup.ServiceGroupService, error) {
	return servicegroup.NewServiceGroupService(c)
}
func ListServiceGroupsHandler(c *routing.Context) error {
	serviceGroupService, _ := getServiceGroupsService(c)
	sg, err := serviceGroupService.GetServiceGroups()
	if err != nil {
		return http.Error(c, strconv.Quote(err.Error()), 400, ServiceDiscoveryServiceName())
	}
	json, _ := json.Marshal(sg)
	return http.Ok(c, string(json), ServiceDiscoveryServiceName())
}
func RegisterServiceGroupHandler(c *routing.Context) error {
	serviceGroup, err := servicediscovery.ValidateServiceGroupBody(c)
	if err != nil {
		return http.Error(c, strconv.Quote(err.Error()), 400, ServiceDiscoveryServiceName())
	}
	serviceGroupService, _ := getServiceGroupsService(c)
	err = serviceGroupService.CreateServiceGroup(serviceGroup)
	if err != nil {
		return http.Error(c, strconv.Quote(err.Error()), 400, ServiceDiscoveryServiceName())
	}
	return http.Created(c, "Service created successfuly", ServiceDiscoveryServiceName())
}
func AddServiceToGroupHandler(c *routing.Context) error {
	serviceGroupID := c.Param("group_id")
	var bodyMap map[string]string
	err := json.Unmarshal(c.Request.Body(), &bodyMap)
	if err != nil {
		return http.Error(c, strconv.Quote(err.Error()), 400, ServiceDiscoveryServiceName())
	}
	if _, ok := bodyMap["service_id"]; !ok {
		return http.Error(c, "Invalid body. Missing service_id", 400, ServiceDiscoveryServiceName())
	}
	if serviceGroupID == "null" || bodyMap["service_id"] == "null" || bodyMap["service_id"] == "" {
		return http.Error(c, "Invalid body", 400, ServiceDiscoveryServiceName())
	}
	serviceGroupService, _ := getServiceGroupsService(c)
	err = serviceGroupService.AddServiceToGroup(serviceGroupID, bodyMap["service_id"])
	if err != nil {
		return http.Error(c, strconv.Quote(err.Error()), 400, ServiceDiscoveryServiceName())
	}
	return http.Created(c, "Service added to group successfuly", ServiceDiscoveryServiceName())
}