// RegisterHandler handles register post request

RegisterHandler handles register post request
// RegisterHandler handles register post request
func RegisterHandler(c *routing.Context) error {
	serviceDiscovery := ServiceDiscovery(c)
	serv, err := servicediscovery.ValidateServiceBody(c)
	if err != nil {
		return http.Error(c, err.Error(), 400, ServiceDiscoveryServiceName())
	}
	_, err = servicediscovery.ValidateServiceExists(serv)
	if err == nil {
		return http.Error(c, `Service already exists.`, 400, ServiceDiscoveryServiceName())
	}
	serv.MatchingURIRegex = sdUtils.GetMatchingURIRegex(serv.MatchingURI)
	serv, err = serviceDiscovery.CreateService(serv)
	if err != nil {
		return http.Error(c, err.Error(), 400, ServiceDiscoveryServiceName())
	}
	return http.Created(c, "Service registered successfuly", ServiceDiscoveryServiceName())
}
func RegisterHandler ( c * routing . Context ) error { serviceDiscovery := ServiceDiscovery ( c ) serv , err := servicediscovery . ValidateServiceBody ( c ) if err != nil { return http . Error ( c , err . Error ( ) , 400 , ServiceDiscoveryServiceName ( ) ) } _ , err = servicediscovery . ValidateServiceExists ( serv ) if err == nil { return http . Error ( c , `Service already exists.` , 400 , ServiceDiscoveryServiceName ( ) ) } serv . MatchingURIRegex = sdUtils . GetMatchingURIRegex ( serv . MatchingURI ) serv , err = serviceDiscovery . CreateService ( serv ) if err != nil { return http . Error ( c , err . Error ( ) , 400 , ServiceDiscoveryServiceName ( ) ) } return http . Created ( c , " " , ServiceDiscoveryServiceName ( ) ) }
RegisterHandler handles register post request
RegisterHandler handles register post request
// Get service discovery object
 // Validate if request body is valid
 // Validate if service already exists
