-
Notifications
You must be signed in to change notification settings - Fork 470
Base URL for ControllerLinkBuilder #516
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
Comments
To achieve that you shouldn't have to (even want to) configure stuff in the application explicitly. If your proxy sets thee appropriate headers ( |
In that case, there is no proxy, just client side load balancing with ribbon. The use case is microservice-to-microservice communication within the same deployment environment, and I wouldn't really need a reverse proxy. I could set headers client side when making the requests (that's what I'm doing), but I feel like I shouldn't have to. Isn't the idea that a service wants to know and link to its own canonical service url that's different from the physical instance address quite logical? To me it seems more flexible than expecting the current physical address to always be the right address to link to. IMO the choice of both approaches would be a nice improvement for HATEOAS, it is not that essential though as there are ways around. |
+1 for being able to create relative links (it's a valid choice that fwiw doesn't break HATEOAS principles -- if browsers can follow relative links, other clients should be able to do so as well), and being able to use ControllerLinkBuilder outside of the request context. |
@olivergierke is there any more feedback I could provide? (seeing the waiting-for-feedback label) |
@olivergierke does label unlikely mean, that you are unlikely to spend time to implement this, or also unlikely you'd accept a contribution? |
In general, I also +1 being able to use In particular, here is my use-case for needing to set a base URL for I did see @olivergierke 's take on link discovery between services, but I'm not convinced that search resources based on primary or secondary business keys are always possible. Plus, polling seems redundant in a CQRS architecture. Using
In the context of microservices fronted by a reverse-proxy or gateway, it seems plausible to assume that no two nodes in the application should use different base URLs in order to contact any third node. |
The original issue was about configuring a Spring HATEOAS application with a base URL. Spring Data REST already provides this, but it's mechanism is rather unique. The conversation drifted over to relative URLs, which was solved for the use case of making web calls outside an existing one. (See #408). Back to the subject at hand, which I think is best summarized as "make my links support an '/api' prefix", @odrotbohm is it possible to define some configuration object that that would support both |
There are several tickets requesting to influence the URLs that the
ControllerLinkBuilder
creates. I'd like to propose another variation:I'd like an option to have
ControllerLinkBuilder
build links with a fixed, configured base URL instead of the information extracted from the servlet request. My use case is having redundant service instances that are accessed by client side load balancing from other services within the same application. I'd like to configure that base URL as an environment property, and in my case usespring.application.name
as host name as this is the service name in eureka. There's a bit more context in this Stack Overflow question.The text was updated successfully, but these errors were encountered: