代码拉取完成,页面将自动刷新
<dependency>
<groupId>com.ipet</groupId>
<artifactId>quick-http</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
//包扫描
@HttpComponentScan("com.ipet.test.rest.http")
@Configuration
@SpringBootApplication
public class ServiceExecutor {
public static void main(String[] args) throws InterruptedException, ExecutionException {
ConfigurableApplicationContext configurableApplicationContext = new SpringApplication(ServiceExecutor.class).run(args);
new CountDownLatch(1).await();
}
}
//http interface声明
@HttpComponent
public interface HttpTestInterface {
//http request 声明
@HttpRequest(value = "http://www.qq.com",header = @Header(key = "Content-Type",value = "text/html"))
String visitQQ();
}
@HttpComponent
public interface HttpTestInterface {
@HttpRequest("https://www.baidu.com")
String visitBaidu();
@HttpRequest(value = "https://www.baidu.com",method = HttpMethod.POST)
String postBaidu();
@HttpRequest(value = "https://www.baidu.com",method = HttpMethod.PUT)
String putBaidu();
@HttpRequest(value = "https://www.baidu.com", method = HttpMethod.DELETE)
String deleteBaidu();
@HttpRequest(value = "https://www.baidu.com", method = HttpMethod.HEAD)
String headBaidu();
@HttpRequest(value = "https://www.baidu.com", method = HttpMethod.OPTIONS)
String optionsBaidu();
}
@HttpComponent
public interface HttpTestInterface {
@HttpRequest(value="https://localhost",certification="/home/ssl/key.crt")
String visitBaidu();
}
@HttpComponent
public interface HttpTestInterface {
//方式一 直接在@HttpRequest注解中通过@Header或者@Headers注解设置固定header
@HttpRequest(value = "http://www.qq.com",header = @Header(key = "Content-Type",value = "text/html"))
String visitQQ();
//方式二 通过入参的方式设置可变header
@HttpRequest("http://www.qq.com")
String visitQQ(@Header(key = "Content-Type") String contentType);
}
@HttpComponent
public interface HttpTestInterface {
@HttpRequest(value = "http://www.qq.com",charset="GB2312")
String visitQQ();
}
@HttpComponent
public interface HttpTestInterface {
@HttpRequest(url = "http://www.qq.com", bufferSize = 16 * 1024)
String visitQQ(@Header(key = "Content-Type") String contentType);
}
@HttpComponent
public interface HttpTestInterface {
@HttpRequest(url = "http://www.qq.com", bufferSize = 16 * 1024, preScript = BeforeRequestScript.class, afterScript = AfterRequestScript.class)
String visitQQ(@Header(key = "Content-Type") String contentType);
}
//前置操作类BeforeRequestScript
public class BeforeRequestScript implements PreRequest {
@Override
public void setRequestMethodMetadata(RequestMethodMetadata requestMethodMetadata) {
//pass the request method metadata
}
@Override
public void doScript() {
//do your things...
}
}
//后置操作类AfterRequestScript
public class AfterRequestScript implements AfterRequest {
@Override
public void doScript() {
//do your things...
}
@Override
public <T> void setResponse(T response) {
//pass the response object
}
@Override
public void setRequestMethodMetadata(RequestMethodMetadata requestMethodMetadata) {
//pass the request method metadata
}
}
@HttpComponent
public interface HttpTestInterface {
//只需要设置返回值为Future类型,自动识别为异步调用
@HttpRequest("https://www.baidu.com")
Future<String> asyncVisitBaidu();
}
qq.url=http://www.qq.com
@HttpComponent
public interface HttpTestInterface {
//http request 声明
@HttpRequest(value = "${qq.url}",header = @Header(key = "Content-Type",value = "text/html"))
String visitQQ();
}
@HttpComponent("${qq.url}")
public interface HttpTestInterface {
//http request 声明
@HttpRequest(header = @Header(key = "Content-Type",value = "text/html"))
String visitQQ();
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
1. 开源生态
2. 协作、人、软件
3. 评估模型