Closed liuziyuan closed 2 months ago
/cc @aloubyansky (extension-proposal), @gastaldi (extension-proposal), @gsmet (extension-proposal), @maxandersen (extension-proposal)
I know about https://square.github.io/retrofit/, but what is easy retrofit? is that some other thing?
biggest issue I have with retrofit is that it seem to depend on okhttp which then drags in a lot of kotlin stdlib dependencies. that's unfortunate.
but +1 for enabling use of retrofit from Quarkus - just be cautious about dependency chain issues this can trigger.
what is easy retrofit? is that some other thing?
The core of easy-retrofit is to implicitly provide retrofit instance injection to the DI framework and enhance the function with more annotations. other thing is, Provides a extension function that can extend the underlying OKHttp Interceptor of Retrofit. The current extension can be seen in the project extension folder.
for example , on official retrofit ,
first, you need to define an interface .second ,you need create a instance of interface, last, you could access http request.
public interface GitHubService {
@GET("users/{user}/repos")
Call<List<Repo>> listRepos(@Path("user") String user);
}
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://api.github.com/")
.build();
GitHubService service = retrofit.create(GitHubService.class);
Call<List<Repo>> repos = service.listRepos("octocat");
on easy retrofit, You just need to declare @EnablingRetrofit Annotation ,second, define an interface. last, inject interface by DI framework, Then you could access http request
@RetrofitBuilder(baseUrl = "${app.hello.url}")
public interface HelloApi {
@GET("v1/hello/{message}")
Call<ResponseBody> hello(@Path("message") String message);
}
@Autowired
private HelloApi helloApi;
@GetMapping("/{message}")
public ResponseEntity<String> hello(@PathVariable String message) throws IOException {
final ResponseBody body = helloApi.hello(message).execute().body();
return ResponseEntity.ok(body.string());
}
Actually, I have already completed the integration of the easy retrofit on quarks extension at my local. Do you need me to push the local git project to GitHub and review it?
and last, @maxandersen thank you +1 for my project extension proposal , I want to know under what circumstances would a project be created for easy retrofit
For more examples, you can take a look at easy-retrofit-readme, but the English readme is not a latest, and for Spring Framework demo at here.
@maxandersen @gastaldi @aloubyansky @gsmet I would like to know when I can create a project for the easy retrofit extension in the Quarkiverse Hub
@liuziyuan I can create a repository for you. Have you already created a protoype as a Quarkus extension (maybe in your personal org) so we can take a look or the plan is to start from zero?
@liuziyuan I can create a repository for you. Have you already created a protoype as a Quarkus extension (maybe in your personal org) so we can take a look or the plan is to start from zero?
@gastaldi In my local , the core functions of the Quarkus easy retrofit project have been completed and I have pushed quarkus-easy-retrofit to my GitHub. This project is just a demo for you to see
you can run integration-tests sub-module, http://localhost:8080/retrofit-client ,and observe the value returned by the retrofit interface
@liuziyuan quarkiverse/quarkus-easy-retrofit is now provisioned. Welcome to Quarkiverse! See hub.quarkiverse.io/checklist/#after-the-repository-is-created for the next steps
thanks for the info @liuziyuan - i took a look at the integration test sub module and wondered what these adapters are for: https://github.com/liuziyuan/quarkus-easy-retrofit/tree/main/integration-tests/src/main/java/io/quarkiverse/easy/retrofit/client/it/retrofit ?
are those something users need to add?
thanks for the info @liuziyuan - i took a look at the integration test sub module and wondered what these adapters are for: https://github.com/liuziyuan/quarkus-easy-retrofit/tree/main/integration-tests/src/main/java/io/quarkiverse/easy/retrofit/client/it/retrofit ?
are those something users need to add?
Essentially, The @RetrofitBuilder is a substitute for Retrofit Retrofit.Builder()
, Retrofit.Builder() provides some methods to assemble the final Retrofit object, and in Easy Retrofit, the same applies.
As for the other files, they are used by me to test the Easy Retrofit Extension function and can be ignored in the demo
For more usage, you can see readme。easy Retrofit readme advanced configuration
@RetrofitBuilder(baseUrl = "${app.url}" ,
addConverterFactory = {JacksonConvertFactoryBuilder.class},
addCallAdapterFactory = {BodyCallAdapterFactoryBuilder.class, GuavaCallAdapterFactoryBuilder.class},
validateEagerly = false,
globalOverwriteRule = OverrideRule.LOCAL_FIRST)
//@RetrofitInterceptor(handler = TestInterceptor.class)
public interface BaseApi {
@GET("api/hello")
Call<ResponseBody> hello();
@GET("backend/v1/hello/abc")
HelloBean helloBean2();
}
Description
Quickly using Retrofit 2 in the Quarkus project, the easy-retrofit provides an annotation based configuration to create Retrofit instances, and enhances general functionality through more annotations. Currently, this project has completed its core functions within the Spring boot framework。 Retrofit is A type-safe HTTP client for Android and Java,Retrofit provides both synchronous and asynchronous HTTP requests。
easy retrofit
website on github easy-retrofit-spring-boot-staterRepository name
quarkus-easy-retrofit
Short description
easy-retrofit-client provides an annotation based configuration to create Retrofit instances, and enhances general functionality through more annotations.
Repository Homepage URL
https://quarkiverse.github.io/quarkiverse-docs/quarkus-easy-retrofit/dev/
Repository Topics
Team Members
Additional context
No response