// AddServiceToGroupHandler handle POST /service-groups

AddServiceToGroupHandler handle POST /service-groups
// AddServiceToGroupHandler handle POST / service - groups
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())
}
func AddServiceToGroupHandler ( c * routing . Context ) error { serviceGroupID := c . Param ( " " ) 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 [ " " ] ; ! ok { return http . Error ( c , " " , 400 , ServiceDiscoveryServiceName ( ) ) } if serviceGroupID == " " || bodyMap [ " " ] == " " || bodyMap [ " " ] == " " { return http . Error ( c , " " , 400 , ServiceDiscoveryServiceName ( ) ) } serviceGroupService , _ := getServiceGroupsService ( c ) err = serviceGroupService . AddServiceToGroup ( serviceGroupID , bodyMap [ " " ] ) if err != nil { return http . Error ( c , strconv . Quote ( err . Error ( ) ) , 400 , ServiceDiscoveryServiceName ( ) ) } return http . Created ( c , " " , ServiceDiscoveryServiceName ( ) ) }
AddServiceToGroupHandler handle POST /service-groups
AddServiceToGroupHandler handle POST / service - groups
// Try to parse body
 // Validate body
 // Create service group service
