class RestTemplateEurekaHttpClient implements EurekaHttpClient {

	private final RestTemplate restTemplate;

	private String serviceUrl;

	public RestTemplateEurekaHttpClient(RestTemplate restTemplate, String serviceUrl) {
		this.restTemplate = restTemplate;
		this.serviceUrl = serviceUrl;
		if (!serviceUrl.endsWith("/")) {
			this.serviceUrl = this.serviceUrl + "/";
		}
	}

	public String getServiceUrl() {
		return this.serviceUrl;
	}

	public RestTemplate getRestTemplate() {
		return restTemplate;
	}

	@Override
	public EurekaHttpResponse<Void> register(InstanceInfo info) {<FILL_FUNCTION_BODY>}

	@Override
	public EurekaHttpResponse<Void> cancel(String appName, String id) {
		String urlPath = serviceUrl + "apps/" + appName + '/' + id;

		ResponseEntity<Void> response = restTemplate.exchange(urlPath, HttpMethod.DELETE, null, Void.class);

		return anEurekaHttpResponse(response.getStatusCode().value()).headers(headersOf(response)).build();
	}

	@Override
	public EurekaHttpResponse<InstanceInfo> sendHeartBeat(String appName, String id, InstanceInfo info,
			InstanceStatus overriddenStatus) {
		String urlPath = serviceUrl + "apps/" + appName + '/' + id + "?status=" + info.getStatus().toString()
				+ "&lastDirtyTimestamp=" + info.getLastDirtyTimestamp().toString()
				+ (overriddenStatus != null ? "&overriddenstatus=" + overriddenStatus.name() : "");

		ResponseEntity<InstanceInfo> response = restTemplate.exchange(urlPath, HttpMethod.PUT, null,
				InstanceInfo.class);

		EurekaHttpResponseBuilder<InstanceInfo> eurekaResponseBuilder = anEurekaHttpResponse(
				response.getStatusCode().value(), InstanceInfo.class).headers(headersOf(response));

		if (response.hasBody()) {
			eurekaResponseBuilder.entity(response.getBody());
		}

		return eurekaResponseBuilder.build();
	}

	@Override
	public EurekaHttpResponse<Void> statusUpdate(String appName, String id, InstanceStatus newStatus,
			InstanceInfo info) {
		String urlPath = serviceUrl + "apps/" + appName + '/' + id + "/status?value=" + newStatus.name()
				+ "&lastDirtyTimestamp=" + info.getLastDirtyTimestamp().toString();

		ResponseEntity<Void> response = restTemplate.exchange(urlPath, HttpMethod.PUT, null, Void.class);

		return anEurekaHttpResponse(response.getStatusCode().value()).headers(headersOf(response)).build();
	}

	@Override
	public EurekaHttpResponse<Void> deleteStatusOverride(String appName, String id, InstanceInfo info) {
		String urlPath = serviceUrl + "apps/" + appName + '/' + id + "/status?lastDirtyTimestamp="
				+ info.getLastDirtyTimestamp().toString();

		ResponseEntity<Void> response = restTemplate.exchange(urlPath, HttpMethod.DELETE, null, Void.class);

		return anEurekaHttpResponse(response.getStatusCode().value()).headers(headersOf(response)).build();
	}

	@Override
	public EurekaHttpResponse<Applications> getApplications(String... regions) {
		return getApplicationsInternal("apps/", regions);
	}

	private EurekaHttpResponse<Applications> getApplicationsInternal(String urlPath, String[] regions) {
		String url = serviceUrl + urlPath;

		if (regions != null && regions.length > 0) {
			url = url + (urlPath.contains("?") ? "&" : "?") + "regions=" + StringUtil.join(regions);
		}

		ResponseEntity<EurekaApplications> response = restTemplate.exchange(url, HttpMethod.GET, null,
				EurekaApplications.class);

		return anEurekaHttpResponse(response.getStatusCode().value(),
				response.getStatusCode().value() == HttpStatus.OK.value() && response.hasBody()
						? (Applications) response.getBody() : null).headers(headersOf(response)).build();
	}

	@Override
	public EurekaHttpResponse<Applications> getDelta(String... regions) {
		return getApplicationsInternal("apps/delta", regions);
	}

	@Override
	public EurekaHttpResponse<Applications> getVip(String vipAddress, String... regions) {
		return getApplicationsInternal("vips/" + vipAddress, regions);
	}

	@Override
	public EurekaHttpResponse<Applications> getSecureVip(String secureVipAddress, String... regions) {
		return getApplicationsInternal("svips/" + secureVipAddress, regions);
	}

	@Override
	public EurekaHttpResponse<Application> getApplication(String appName) {
		String urlPath = serviceUrl + "apps/" + appName;

		ResponseEntity<Application> response = restTemplate.exchange(urlPath, HttpMethod.GET, null, Application.class);

		Application application = response.getStatusCode().value() == HttpStatus.OK.value() && response.hasBody()
				? response.getBody() : null;

		return anEurekaHttpResponse(response.getStatusCode().value(), application).headers(headersOf(response)).build();
	}

	@Override
	public EurekaHttpResponse<InstanceInfo> getInstance(String appName, String id) {
		return getInstanceInternal("apps/" + appName + '/' + id);
	}

	@Override
	public EurekaHttpResponse<InstanceInfo> getInstance(String id) {
		return getInstanceInternal("instances/" + id);
	}

	private EurekaHttpResponse<InstanceInfo> getInstanceInternal(String urlPath) {
		urlPath = serviceUrl + urlPath;

		ResponseEntity<InstanceInfo> response = restTemplate.exchange(urlPath, HttpMethod.GET, null,
				InstanceInfo.class);

		return anEurekaHttpResponse(response.getStatusCode().value(),
				response.getStatusCode().value() == HttpStatus.OK.value() && response.hasBody() ? response.getBody()
						: null).headers(headersOf(response)).build();
	}

	@Override
	public void shutdown() {
		// Nothing to do
	}

	private static Map<String, String> headersOf(ResponseEntity<?> response) {
		HttpHeaders httpHeaders = response.getHeaders();
		if (httpHeaders == null || httpHeaders.isEmpty()) {
			return Collections.emptyMap();
		}
		Map<String, String> headers = new HashMap<>();
		for (Entry<String, List<String>> entry : httpHeaders.entrySet()) {
			if (!entry.getValue().isEmpty()) {
				headers.put(entry.getKey(), entry.getValue().get(0));
			}
		}
		return headers;
	}

}

		String urlPath = serviceUrl + "apps/" + info.getAppName();

		HttpHeaders headers = new HttpHeaders();
		headers.add(HttpHeaders.ACCEPT_ENCODING, "gzip");
		headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);

		ResponseEntity<Void> response = restTemplate.exchange(urlPath, HttpMethod.POST, new HttpEntity<>(info, headers),
				Void.class);

		return anEurekaHttpResponse(response.getStatusCode().value()).headers(headersOf(response)).build();
	
<no_super_class>