OpenFeign / OpenFeign/feign

Support one-time configuration of expression parameters

Open
#1,412 12 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

proposal
Dominant language
Java
Stars
9.8k
Forks
1.9k
Avg merge
1d 2h
Merged PRs (30d)
41

Description

Problem

Let's say I have a request template that looks like this:

@RequestLine("GET /{env}/{resource}")
void getResource(@Param("env") String env, @Param("resource") String resource);

In the application that defines this template, env is configured at startup and will only ever have 1 value (e.g. "production" or "qa") during the application's lifespan. It would make sense to not have to pass this same value into each call of getResource().

Default methods are of no help here because env still needs to be dynamically set.

Proposal

Support on-time configuration of expression parameters via configuration methods on the client interface:

@Configuration
void setEnv(@Param("env") String env);

@RequestLine("GET /{env}/{resource}")
void getResource(@Param("resource") String resource);

Implementing this is pretty easy (~150 lines).

N.B. this proposal is somewhat similar to https://github.com/OpenFeign/feign/issues/1359.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files, tests, or entry points are named. Start by tracing how Feign processes @RequestLine, @Param, and interface configuration methods, then determine where a configured parameter can be retained and applied to later calls; done means one-time configuration removes that value from each request method's arguments.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.