question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support multiple urls in @RequestMapping on FeingClient

See original GitHub issue

I 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:closed
  • Created 6 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
leonardovillelacommented, Jan 23, 2018

Why you discourage sharing interfaces between server and client?

0reactions
zsalabcommented, Aug 19, 2019

There could be multiple urls with gridIdentfier in them, which to choose? This is a client, not a server. You need to make two separate methods in your feign interface.

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found