How to Implement Custom Cache Mechanism with Kotlin Multiplatform(Android, iOS) Ktor Client - ktor

I am working on Kotlin Multiplatform Project. I used Ktor Client for Network calls. I want to cache some request based on some custom logic not based on response header.
HttpCache feature provided by Ktor is Response Header driven and I am not able to override it because number of Classes is Internal.
How can i enable Ktor to work with custom cache?

Related

Mock Open API endpoints that havenā€˜t been implemented yet?

Mocking endpoints an Open API Specification file defines isn't all that difficult.
However I am trying to mock only the endpoints that don't have an implementation yet.
For example I have an OAS file that defines an GET /dogs and an GET /cats endpoint.
Now when I implement GET /dogs in a - for example - Nest.js application and that application is running, I would want to have a mock server that only mocks the GET /cats endpoint.
That would make it possible to bundle the mock server and the application and to deploy them together, so that some form of response (either the implementation or the mocked) is always returned for every endpoint.
Is there some sort of tool/mock-server that has this kind of ability? Would doing something like that even make sense?

Quarkus Jax-rs clients with external interfaces

I started playing around with Quarkus and its REST client. According to the documentation a Jax-RS annotated interface should be created and annotated further with #RegisterRestClient.
My issue is that I already have the JaxRS interfaces for the services I need to connect to, in an artifact provided by the server, which I can just import. Is there a way to use an already created external Jax-RS interface to create a service with? It seems so wrong to copy-paste the code for a perfectly good interface, when it has been so nicely served for me.
There's RestClientBuilder, which allows programmatic usage of JAX-RS interfaces. Assuming the JAX-RS interface is called HelloClient, you can do this:
HelloClient client = RestClientBuilder.newBuilder()
.baseUri(URI.create("http://localhost:8080"))
.build(HelloClient.class);

Header propagation with Flurl and DotNetCore

I've really enjoyed using Flurl the last year but have encountered a problem that Im hoping I can solve using Flurl if possible and not resort ripping it out and using IHttpClientFactory and HttpClient from System.Net.Http
I've got a DotNetCore 3.1 API and our client is calling these APIs with custom headers. "x-activityid" as an example. My API calls out to an external API and so I've created a separate Client class where im calling the endpoints on the external API using Flurl.
I need to propagate some of the headers from the requests incomming to my API to the requests I make to the external API that Im calling using Flurl.
Some related links:
Header propagation using ASP.NET Core
Make HTTP requests using IHttpClientFactory in ASP.NET Core
The whole idea of header propagation depends on awareness of some HTTP server context from which to grab the incoming headers, which is why ASP.NET Core can support such a feature directly while Flurl, a stand-alone library that often gets embedded in things like Xamarin apps, cannot.
But all is not lost, because Flurl is really just a wrapper around HttpClient. To get this feature to work without giving up Flurl, just wire up header propagation in ASP.NET Core exactly as prescribed, allow it to inject HttpClient instances into your service classes, then wrap those instances with Flurl inside those classes. Note that you'll need to adapt the pattern of using FlurlClient directly, as opposed to building calls off URL strings, if you're not doing that already.

http requests with Kotlin multiplatform for desktop

I'm new to kotlin multiplatform and I'm using compose for desktop, how can I make HTTP requests?
is there any resources to learn from?
Ktor is the best supported multiplatform HTTP client currently, as it is maintained by Jetbrains There are also projects that put together many open source tools for kotlin multiplatform such as: AAkira
There is not a specific place currently that goes over HTTP communication, as it would be specific per tool you choose.

How to use request and session scopes in spring-webflux (as of latest releases)

I am developing a rest web service using reactive programming through spring-webflux(Spring Boot 2.1 and Spring Framework 5.1). I need to create components having request level scope. #Scope annotation is suggested for spring MVC applications. But I found that the same doesn't work with webflux application.
Is there an equivalent feature available in webflux, as of latest release?
If not, what shall be the workaround here to create a new instance of a component on every incoming request?
I am trying to avoid use of new operator.
Thank you for the suggestions.
Unfortunately you cannot use request scopes in spring-webflux like in spring MVC applications. The main reason being, they use ThreadLocals which cannot be used by spring-webflux as work can be done on any thread at any time.
Spring webflux uses project-reactor at its core. So you can use Reactor Context which allows you to share data in your reactive pipeline.