Skip to content

Support SPEL expressions in @HttpExchange and related annotations #30125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
originalrusyn opened this issue Mar 16, 2023 · 5 comments
Closed
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: duplicate A duplicate of another issue

Comments

@originalrusyn
Copy link

I would like to avoid hardcoding of url template in these annotations to be able to change it via configuration properties.
So, I would like to be able specify configuration property in these annotations, for example:

@GetExchange("${app.api.url}") - where app.api.url is a configuration property key

and

@GetExchange("#{@app.api.url}") - where app is some bean annotated with @ConfigurationProperties

Could you please implement such thing?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Mar 16, 2023
@bclozel
Copy link
Member

bclozel commented Mar 16, 2023

Supporting SpEL expressions in such annotations is one thing and we can consider this.

In this case, I think the best course of action would be configure that URL as the base URI used by the HTTP client used when generating the proxy. Have you tried this approach?

@originalrusyn
Copy link
Author

In this case, I think the best course of action would be configure that URL as the base URI used by the HTTP client used when generating the proxy. Have you tried this approach?

No, I haven't because it wouldn't do what I want anyway (I would like to avoid hardcoding of any part of url template in such annotations. But in this case I still would have to specify relative part of url template in the annotation).

@rstoyanchev
Copy link
Contributor

These are not SpEL expressions, but property placeholders, and we already resolve these, see #28492. Make sure that you are setting embeddedValueResolver on the HttpServiceProxyFactory builder.

@rstoyanchev rstoyanchev added the status: waiting-for-feedback We need additional information before we can continue label Mar 27, 2023
@originalrusyn
Copy link
Author

originalrusyn commented Mar 27, 2023

@rstoyanchev

Ok, after following change it works.

Thanks

var httpServiceProxyFactory = HttpServiceProxyFactory.builder(webClientAdapter)
            .embeddedValueResolver(configurableBeanFactory::resolveEmbeddedValue)
            .build();

(Now It would be nice that Intelij IDEA to support property placeholders in these annotations)

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Mar 27, 2023
@rstoyanchev rstoyanchev closed this as not planned Won't fix, can't repro, duplicate, stale Mar 27, 2023
@rstoyanchev rstoyanchev added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged or decided on status: feedback-provided Feedback has been provided labels Mar 27, 2023
@sbrannen sbrannen added the in: web Issues in web modules (web, webmvc, webflux, websocket) label Aug 2, 2023
@sbrannen sbrannen changed the title Support SPEL expressions in @HttpExchange and in its shortcuts Support SPEL expressions in @HttpExchange and related annotations Aug 2, 2023
@xenoterracide
Copy link

So this got closed, but is it because there's no interest in supporting spel expressions? I would like spel expressions because I would like to use properties on objects in the current request scope. AFAIK the only way I'm going to get a correlation ID that I stuff into the request scope as a bean into an HTTP interface whilst trying to avoid passing it around is a spel expression. Am I wrong about that? either way could we get spel expression support?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

6 participants