Announcement Announcement Module
Collapse
No announcement yet.
Set port number Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Set port number

    Hi,
    I want to do something very easy, but I've nothing found in the documentation.
    I want to set the port number for the URI I request. For instance in restTemplate.exchange(), but there is no possibility to do that.

    I don't want to use the way http://myurl.com:8080 or something like that, because in my app the user has the possibility to add a custom URI and if he adds something like http://myurl.com/someDir, I can't just add the port :8080 to the end. Sure, I could manipulate the string, but I'm looking for a clean solution.

    Someboy any idea?

    Thx in advance!
    Steffo

  • #2
    I think you could use path variables. For example:

    String URL = "http://{hostname}:{port}/{resource}/{id}"

    // These values can be retrieved from your application UI
    String hostname = "www.steffo.com";
    String resource = "post"
    String id = "1";

    String result = restTemplate.getForObject(URL, String.class, hostname, resource, id);


    Best Regards!

    Comment


    • #3
      Hi,
      thanks for your reply. But isn't it the way I wanted to avoid like I stated in my first post?
      My problem is, that the user could enter in some form an address like "www.steffo.com/someResource". I have then to manipulate the string in order to set the port like you suggested. Do you understand my problem?

      Best regards
      Steffo

      Comment

      Working...
      X