spring-cloud-openfeign icon indicating copy to clipboard operation
spring-cloud-openfeign copied to clipboard

Feign doesn't support regexp in request mapping

Open asm0dey opened this issue 8 years ago • 6 comments

If I use interface

public interface UserAPI {
  @RequestMapping(method = GET, path = "/user/{username:[a-z@A-Z\\d\\.-_]+}"
  UserDTO getUserByUsername();
}

And want to create client as

@FeignClient("service")
public interface UserClient extends UserAPI{}

it won't work because feign thinks that pattern is part of path. It's even more impressive if you want to use pattern like .+

asm0dey avatar Feb 08 '16 09:02 asm0dey

Any timeframe on this being included in an upcoming release?

jmgilmour avatar May 02 '17 23:05 jmgilmour

@jmgilmour no. PRs welcome.

spencergibb avatar May 02 '17 23:05 spencergibb

Thanks for the quick response. I was under the impression that the referenced commit by @venilnoronha above would fix this issue.

jmgilmour avatar May 02 '17 23:05 jmgilmour

That commit merely didn't error if there was a regex, it didn't support them.

spencergibb avatar May 03 '17 00:05 spencergibb

Good to know :smile:. I guess I'll take a crack at a fix and PR when I get the chance. Again, thanks for the quick response.

jmgilmour avatar May 03 '17 00:05 jmgilmour

Support for this was added in feign-core 10.x as part of the uri expression updates. It's now possible to define an expression with a pattern and the pattern will be enforced during expansion. Might be straightforward to take advantage here.

kdavisk6 avatar Feb 06 '19 19:02 kdavisk6