🤗 ApiHug × {Postman|Swagger|Api...} = 快↑ 准√ 省↓
- GitHub - apihug/apihug.com: All abou the Apihug
- apihug.com: 有爱,有温度,有质量,有信任
- ApiHug - API design Copilot - IntelliJ IDEs Plugin | Marketplace
The Next Generation API Development Platform - ApiHug
文中代码都在: HTTP Client Exampleopen in new window。
#创建
public static void main(String[] args) {
HttpClient client = HttpClient.create(); // <1>
client
.get() // <2>
.uri("https://example.com/") // <3>
.response() // <4>
.block();
}
<1>
创建一个HttpClient
实例用来进行的配置操作。<2>
指定使用GET
方法<3>
指定路径地址<4>
获取响应HttpClientResponse
链接 websocket:
public static void main(String[] args) {
HttpClient client = HttpClient.create();
client
.websocket()
.uri("wss://echo.websocket.org")
.handle(
(inbound, outbound) -> {
inbound.receive().asString().take(1).subscribe(System.out::println);
final byte[] msgBytes = "hello".getBytes(CharsetUtil.ISO_8859_1);
return outbound
.send(
Flux.just(Unpooled.wrappedBuffer(msgByte