Here is Freeman's homepage.
Programming and art enthusiast.
๐ฑ Keep studying.
๐ Keep programming.
๐ Keep thinking.
๐ Keep creating.
๐ WORLD PEACE ๐
The missing starter for Spring 6.x declarative HTTP client. Eliminate boilerplate code, server base implementation code generation, RequestMapping annotation support, loadbalancer support, native-image support, dynamic refreshing, dynamic request timeout, and more!
Home Page: https://danielliu1123.github.io/httpexchange-spring-boot-starter/
License: MIT License
http-exchange:
default-base-url: http://api-gateway
default-response-timeout: 10000
default-headers:
X-Header1: v1
X-Header2: [v1, v2]
clients:
- name: OrderApi
base-url: http://order
response-timeout: 1000
- name: UserApi
base-url: http://user
response-timeout: 2000
The current settings can only be set on a single client. It cannot set the read timeout for a single request.
see #33
Support Spring web server side annotation, like Spring Cloud Openfeign
.
e.g. @GetMapping
, @PostMapping
.
@RequestMapping("/foo")
class FooApi {
@GetMapping("/{id}")
Foo getFooById(@PathVariable String id);
}
see #33 (comment)
This library is really well made.
It is a spring feature that can be easily applied right away.
I have to use both the normal return type and the return type of Reactive Stream through the http interface.
Also, I would like to adjust the timeout dynamically.
Therefore, I hope it works as follows.
I wish each channel could have a separate remote client.
http-exchange:
enabled: true
refresh:
enabled: false
read-timeout: 2000
connect-timeout: 500
#client-type: WEB_CLIENT
channels:
- base-url: 'https://jsonplaceholder.typicode.com'
#client-type: REST_CLIENT #here
#read-timeout: 500
#connect-timeout: 200
clients:
- com.devljh.module.http.*HttpClient
- base-url: 'https://jsonplaceholder.typicode.com'
#client-type: WEB_CLIENT #here
clients:
- com.devljh.module.http.*ReactiveHttpClient
It doesn't work now, and an error occurs because the rest client cannot convert Mono/Flux messages.
Api:
@Validated
@HttpExchange("/user")
public interface UserApi {
@GetExchange("/{id}")
UserDTO getUser(@PathVariable("id") @NotBlank @Length(max = 5) String id);
}
Generate default implementation for server:
// Generate interface
@Validated
@HttpExchange("/user")
public interface UserApiBase {
@GetMapping("/{id}")
default UserDTO getUser(@PathVariable("id") @NotBlank @Length(max = 5) String id) {
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED);
}
}
In the buildRestClient method, HttpClient settings other than timeout are unintentionally initialized.
RequestConfigurator
is suitable for client-side use, but not for a neutral API definition. There is a need to provide coding support for read timeout setting.
see RestClient.
Love what you did with this.
I am curious about how you generated your Wiki. I'm assuming from your README.md file some frontend library you used?
Thank you!
Api:
@Validated
@HttpExchange("/user")
public interface UserApi {
@GetExchange("/{id}")
UserDTO getUser(@PathVariable("id") @NotBlank @Length(max = 5) String id);
}
Generate base implementation for server:
// generate interface?
public interface UserApiBase extends UserApi {
@Override
default UserDTO getUser(String id) {
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED);
}
}
// or generate abstract class? Just like gRPC
public abstract class UserApiBase implements UserApi {
@Override
public UserDTO getUser(String id) {
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED);
}
}
Maybe generate abstract class is a better chioce? Generation interface may lead to unexpected behavior(@Validated
not work as expected).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.