Support one-time configuration of expression parameters
See original GitHub issueProblem
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.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:12 (11 by maintainers)
Top Results From Across the Web
Optional General Server Parameters - Genesys
For PureConnect Cloud customers only. This parameter determines whether the system provides usage-based billing data for Speech (ASR/TTS). If this parameter is ...
Read more >Framework Types Supporting Expression Trees
Learn about framework types supporting expression trees, creating expression trees, and techniques for working with expression tree APIs.
Read more >How to specify the commandline parameter expression to ...
1 of the plugin: $ mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version [INFO] ...
Read more >16.4. Run-time Configuration - PostgreSQL
One parameter is specified per line. The equal sign between name and value is optional. Whitespace is insignificant and blank lines are ignored....
Read more >Creating an Amazon EventBridge rule that runs on a schedule
EventBridge supports cron expressions and rate expressions. Rate expressions are simpler to define and cron expressions offer the detailed schedule control.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

The more I think about this, the more I like the idea of expanding
@Paramto be used at the method and class level. Here’s an example:This approach meets the initial request, can be included by
Contractextensions already out in the ecosystem without modification, and provides full control over how the parameter is resolved.Changes to make this possible would be limited refactoring the current
@Paramannotation processor into a dual purpose process that can be registered on the class, method, and parameter:@hellproxy does this meet your needs? @velo any feedback?
I’m looking towards the annotation processor, but we can figure that out later. Let’s move forward with your suggestions.