Skip to content
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

Idea: Unify methods to get endpoint url #33

Open
bitxon opened this issue May 2, 2023 · 1 comment
Open

Idea: Unify methods to get endpoint url #33

bitxon opened this issue May 2, 2023 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed testcontainers

Comments

@bitxon
Copy link
Contributor

bitxon commented May 2, 2023

Proposal

Goal is to simplify public interface of the WireMockContainer class

Current methods

public String getEndpoint() {
  return String.format("http://%s:%d", getHost(), getMappedPort(PORT));
}
public URI getRequestURI(String relativePath) throws URISyntaxException {
  return new URI(getEndpoint() + "/" + relativePath);
}

Option 1

Align method names with WireMockServer class

public String baseUrl() {
  return String.format("http://%s:%d", getHost(), getMappedPort(PORT));
}
public String url(String path) {
  if (!path.startsWith("/")) {
    path = "/" + path;
  }
  return baseUrl() + path;
}

Motivation

  1. Simplify switch from Embedded wiremock to Testcontainer
  2. Familiar api for developers

Option 2

  public String getEndpoint() {
    return String.format("http://%s:%d", getHost(), getMappedPort(PORT));
  }
  public String getEndpoint(String path) {
    if (!path.startsWith("/")) {
      path = "/" + path;
    }
    return getEndpoint() + path
  }

Motivation

  1. Use Overloaded methods getEndpoint
    • naming consistency
    • easier for developer to memorize and intuitively understand what method does
  2. Allow path to be with / and without it
  • simplify switch from WireMockServer to WireMockTestcontainer

References

No response

@bitxon bitxon added the enhancement New feature or request label May 2, 2023
@oleg-nenashev
Copy link
Member

+1 for alignment of the methods, or maybe even having a shared interface in the [far] future

bitxon added a commit to bitxon/wiremock-testcontainers-java that referenced this issue May 6, 2023
bitxon added a commit to bitxon/wiremock-testcontainers-java that referenced this issue May 6, 2023
bitxon added a commit to bitxon/wiremock-testcontainers-java that referenced this issue May 6, 2023
bitxon added a commit to bitxon/wiremock-testcontainers-java that referenced this issue May 10, 2023
bitxon added a commit to bitxon/wiremock-testcontainers-java that referenced this issue May 13, 2023
oleg-nenashev added a commit that referenced this issue May 14, 2023
#33 Align methods of WireMockContainer and WireMockServer
@oleg-nenashev oleg-nenashev added testcontainers help wanted Extra attention is needed labels Oct 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed testcontainers
Projects
None yet
Development

No branches or pull requests

2 participants