cn.majingjing.http.client.HttpClient Maven / Gradle / Ivy
package cn.majingjing.http.client;
import cn.majingjing.http.client.config.HttpClientConfig;
import cn.majingjing.http.client.request.CustomRequest;
import cn.majingjing.http.client.request.GetRequest;
import cn.majingjing.http.client.request.PostRequest;
import cn.majingjing.http.client.request.RequestMethod;
import cn.majingjing.http.client.util.SslUtils;
/**
* Http client
*
* @author MaMarion
* @date 2020-04-17
*/
public enum HttpClient {
/**
* Single Instance
*/
Instance;
private final HttpClientConfig config = new HttpClientConfig();
HttpClient() {
SslUtils.ignoreAllSsl();
}
/**
* Get方式的请求对象
*
* @param url 请求地址
* @return Get请求对象
*/
public static GetRequest get(String url) {
return new GetRequest(url);
}
/**
* Post方式的请求对象
*
* @param url 请求地址
* @return Post请求对象
*/
public static PostRequest post(String url) {
return new PostRequest(url);
}
/**
* 自定义方式的请求对象
*
* @param method 请求方式
* @param url 请求地址
* @return CustomRequest
*/
public static CustomRequest custom(String method, String url) {
return new CustomRequest(url, method);
}
/**
* 获取全局配置
* @return HttpClientConfig
*/
public HttpClientConfig getConfig() {
return config;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy