OpenFeign / OpenFeign/feign

New Feature: Support for variable contexts on URIs

Open
#1,359 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

It would be nice if via an annotation at class or method level, there could be a means of specifying an implentation that could supply dynamic values to contexts. Consider the following examples:

@VariableContext(alias = "varCtx", supplier = TheValueSupplier.class)
public class Example {

    @Headers({
        "accept: application/json",
    })
    @RequestLine("GET /api/{varCtx}/someEntity/{id}")
    SomeEntity getById(@Param("id") Long id);

}

As it is obvious, the {varCtx} does not need to be passed explicitely via the method's argument. It would also be nice to give the same annotation precedence if placed over a method while one is marking the enclosing class too.

I think this is very handy for cases where a dynamic switch of APIs is needed e.g. between versions (/api/v1/my/path to /api/v2/my/path) or other circumstances (/api/my/path to /api/session/my/path)

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

The issue names @VariableContext, @RequestLine, and @Param but no repository files or tests. Start by tracing URI template and context resolution around @RequestLine, then define tests for class-level and method-level suppliers, including method precedence; done means dynamic values are substituted without an explicit parameter.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.