feign icon indicating copy to clipboard operation
feign copied to clipboard

Is it safe to use RequestTemplate#MethodMeta?

Open Dainerx opened this issue 5 months ago • 0 comments

Hello question (could not label the issue),

My goal is to get the url template without the host and port.

Given: https://{{host}}:{{port}}/v1/api/resource/{id}} Wanted: /v1/api/resource/{id}

Today, this can be achieved by calling methodMetadata. However, it is annotated with Experimental

@Experimental
public RequestTemplate methodMetadata(MethodMetadata methodMetadata) {
    this.methodMetadata = methodMetadata;
    return this;
}

I am using it, in production code, as follow:

templatedRouted = request.requestTemplate().methodMetadata().template().path();

--

First things first, I would have preferred to use requestTemplate.uriTemplate() but uriTemplate field is not exposed as of today. Moreover requestTemplate.url() appends the path (https://github.com/OpenFeign/feign/blob/master/core/src/main/java/feign/RequestTemplate.java#L546).

Is it safe to use methodMetadata()? Have you gathered enough data to make a decision? Finally, should I check against nil?

Thanks!

Dainerx avatar Aug 25 '25 16:08 Dainerx