I need some help) I'm doing some little project with spring boot openfeign client. I have to do 4 http requests. From first GET request I need to get "set-cookie" header out of him get session id. This session ID I need to use in 3 subsequent request (POST, PUT and DELETE). Don't understand clearly how to do it with openfeign. I did it with rest template, but now I need help
enter image description here I did FeignClient interface (hopefully right) and now I have to implement these methods in service class
Try use apache HttpClient.
Configure Feign to Use Apache HttpClient
Create a configuration class for your Feign client that customizes Apache HttpClient to capture cookies. This is just a simple example. In practice, your session should be stored in a better way.
Define the Feign Client
Define a Feign client that will use the above configuration. This client will make the GET, POST, PUT, and DELETE requests.
Use the Feign Client
Finally, use the configured Feign client in your service to perform the HTTP requests.
FeignClientConfig: This configuration class customizes the Apache HttpClient used by Feign. It intercepts all HTTP responses to capture any Set-Cookie header and saves its value. Then, it uses a RequestInterceptor to apply this captured cookie to all subsequent requests made by the Feign client.
ApiClient: Defines the endpoints for your initial and subsequent requests.
ApiService: Uses the ApiClient to first make an initial request to capture the session cookie, then reuses this cookie for further requests.
The idea and steps are roughly the example above, and you need to deal with storing and invalidating cookies