Support multiple urls in @RequestMapping on FeingClient
See original GitHub issueI am using Feign for requesting a MicroService route, but some params of the path variable are optional, i’m trying to define, multiple values for path value to handle with optional parameters, but when I do this I get an exception described below, i think this is a great and helpful feature when interfaces have optional parameters in path.
Spring Cloud Version: org.springframework.cloud:spring-cloud-dependencies:Brixton.SR6
Exception Recived with Mutiple paths:
Caused by: java.lang.IllegalStateException: Method createDocument can only contain at most 1 value field. Found: [/fields/{fieldName}/documents/create, grids/{gridIdentifier}/fields/{fieldName}/documents/create]
Feign client method definition:
@RequestMapping(
method = POST,
path = { "/fields/{fieldName}/documents/create", "grids/{gridIdentifier}/fields/{fieldName}/documents/create"},
produces = APPLICATION_JSON_UTF8_VALUE,
consumes = APPLICATION_JSON_UTF8_VALUE
)
ResponseEntity<ResourceContent<Document>> createDocument(
@PathVariable("fieldName") String fieldName,
@PathVariable(value = "gridIdentifier", required = false) String gridIdentifier,
@RequestBody CreateDocument createDocument
);
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
23. Declarative REST Client: Feign - Spring Cloud
If we want to create multiple feign clients with the same name or url so that they would point to the same server...
Read more >How to call url with multiple query string params in FeignClient?
All Query parameters will automatically be extracted from the url by a split using the & character and mapped to the corresponding @ ......
Read more >Introduction to Spring Cloud OpenFeign - Baeldung
Feign supports multiple clients for different use cases, including the ApacheHttpClient, which sends more headers with the request, for example, ...
Read more >How to configure fiegn clients to perform HTTP requests in ...
In this tutorial, we will discuss how to configure and customize OpenFeign clients to perform the HTTP functions GET, PUT, POST & DELETE....
Read more >Multiple Configurations for Feign Clients - Amir Shokri - Medium
Consider a Feign client that must be used with different configurations at different places in the code, or multiple Feign clients that each ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Why you discourage sharing interfaces between server and client?
I do not get your point, I think this is a really wise idea to map and use same controller / client for multiple URLs like if a resource mapped to multiple owners (yes I know many people thinks that bad design, but nobody had a good reason). Oh and the client can chose pretty easy which URL to call, based on the provided path parameters… those has names and all have to have unique name… so call the URL where the path parameters count and the names are same then in the URL