package test.com.leanwo.common;

import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.client.RestTemplate;

public class RestResourceTest {
	/**
	 * 获取API地址
	 * @param api
	 * @return
	 */
	public String getApiUrl(String api) {
		return "http://localhost:82/activiti/explorer/" + api;
	}
	
	/**
	 * 获取请求头
	 * @return
	 */
	public HttpHeaders getHttpHeaders() {
        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.APPLICATION_JSON);
		headers.add("account", "2");
		headers.add("token", "123456");
		return headers;
	}
	
	/**
	 * 获取RestTemplate
	 * @return
	 */
	public RestTemplate getRestTemplate() {
		RestTemplate restTemplate = new RestTemplate();		
		restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
		return restTemplate;
	}
}
