spring-cloud / spring-cloud-openfeign

Support for using OpenFeign in Spring Cloud apps
Apache License 2.0
1.2k stars 779 forks source link

Feign Client is generating trailing slash in the request #1070

Open lucasoares opened 3 weeks ago

lucasoares commented 3 weeks ago

Describe the bug

Spring is deprecating the trailing slash automatic support: https://github.com/spring-projects/spring-framework/issues/28552

In my tests I notice all my servers using feign clients started to throw a not found error after the update.

Will spring cloud feign follow spring definitions and stop adding trailing slash? Or at least make it configurable? I'm reporting it as a bug since it is a breaking change in the spring versions.

Sample

package foo.bar.api;

import br.com.stilingue.upmslegacy.core.usergroup.entities.Company;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

@FeignClient(
    contextId = "TestApi",
    name = "TestApi",
    path = "/foo",
    url = "${my.api.test:}")
public interface CompanyLegacyApi {
  @GetMapping
  String getTest(@RequestParam String name);
}

When I use the #getTest method and my.api.test points to, for example, http://localhost:8080, the generated URL will be http://localhost:8080/foo/ instead of http://localhost:8080/foo, which will throw an error if requesting a server with the latest spring version.

I'm using spring boot 3.3.3 and 4.1.3 starter-openfeign.

OlgaMaciaszek commented 6 days ago

Thanks @lucasoares. From the perspective of SC OpenFeign, this is not a bug, however, this is something that we should implement for this release. I'd make it configurable with a property, and with the next major, we could make it default.

lucasoares commented 6 days ago

Thanks @lucasoares. From the perspective of SC OpenFeign, this is not a bug, however, this is something that we should implement for this release. I'd make it configurable with a property, and with the next major, we could make it default.

From the perspective of the SPRING Cloud OpenFeign it started being a bug in the same moment the spring boot GA release changed its default behavior on how to deal with trailing slash...

But yes, it should be a configuration available since Spring Boot itself has its own way to configure if the trailing slash will be accepted.

Thanks.