
me.saro.commons.web.Web Maven / Gradle / Ivy
The newest version!
package me.saro.commons.web;
import java.io.File;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import me.saro.commons.Converter;
import me.saro.commons.Files;
import me.saro.commons.function.ThrowableConsumer;
import me.saro.commons.function.ThrowableFunction;
import me.saro.commons.json.JsonReader;
/**
* Web Client
* @author PARK Yong Seo
* @since 0.1
*/
public interface Web {
/**
* create get method Web
* @param url
* @return
*/
public static Web get(String url) {
return new BasicWeb(url, "GET");
}
/**
* create post method Web
* @param url
* @return
*/
public static Web post(String url) {
return new BasicWeb(url, "POST");
}
/**
* create put method Web
* @param url
* @return
*/
public static Web put(String url) {
return new BasicWeb(url, "PUT");
}
/**
* create patch method Web
* @param url
* @return
*/
public static Web patch(String url) {
return new BasicWeb(url, "PATCH");
}
/**
* create delete method Web
* @param url
* @return
*/
public static Web delete(String url) {
return new BasicWeb(url, "DELETE");
}
/**
* request charset
* @return
*/
public String getRequestCharset();
/**
* response charset
* @return
*/
public String getResponseCharset();
/**
* create custom method Web
* @param url
* @return
*/
public static Web custom(String url, String method) {
return new BasicWeb(url, method);
}
/**
* Connect Timeout
* @param connectTimeout
* @return
*/
public Web setConnectTimeout(int connectTimeout);
/**
* Read Timeout
* @param readTimeout
* @return
*/
public Web setReadTimeout(int readTimeout);
/**
* set request Charset
* @param charset
* @return
*/
public Web setRequestCharset(String charset);
/**
* set response charset
* @param charset
* @return
*/
public Web setResponseCharset(String charset);
/**
* ignore https certificate
*
* this method not recommend
*
* ignore certificate is defenseless the MITM(man-in-the-middle attack)
* @param ignoreCertificate
* @return
*/
public Web setIgnoreCertificate(boolean ignoreCertificate);
/**
* add url parameter
*
* always append url parameter even post method
*
* is not body write
* @param name
* @param value
* @return
*/
public Web addUrlParameter(String name, String value);
/**
* set header
* @param name
* @param value
* @return
*/
public Web setHeader(String name, String value);
/**
* write body binary
* @param bytes
* @return
*/
public Web writeBody(byte[] bytes);
/**
* writeBodyParameter
*
* WARNING : is not json type
*
*
* web
*
* .writeBodyParameter("aa", "11")
*
* .writeBodyParameter("bb", "22");
*
* equals
*
* aa=11&bb=22
* @param name
* @param value
* @return
*/
public Web writeBodyParameter(String name, String value);
/**
* to Custom result
* @param result
* @param function
* @return
*/
public WebResult toCustom(WebResult result, ThrowableFunction function);
/**
* to Custom result
* @param function
* @return
*/
default public WebResult toCustom(ThrowableFunction function) {
return toCustom(new WebResult(), function);
}
/**
* to Map result by JsonObject
* @return
*/
default public WebResult
© 2015 - 2025 Weber Informatics LLC | Privacy Policy