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

[http-client] Allow paths to be loaded from System Properties/Avaje Config #323

Merged
merged 2 commits into from
Oct 18, 2023

Conversation

SentryMan
Copy link
Collaborator

@SentryMan SentryMan commented Oct 18, 2023

Now can dynamically determine the paths at runtime using system properties or avaje config.

With this, we can perform tomfoolery such as:

@Client
public interface TitanFall {

  @Get("/${titan}/${drop.point}")
  Titan titanfall();
}

and the following will generate

@Generated("avaje-http-client-generator")
public class TitanFallHttpClient implements TitanFall {
  private final HttpClient client;
  public TitanFallHttpClient(HttpClient client) {
    this.client = client;
  }
                                //if available will use Config.get instead 
  private static final String DROP_POINT = System.getProperty("drop.point");
  private static final String TITAN = System.getProperty("titan");
  // GET /${titan}/${drop.point}
  @Override
  public Titan titanfall() {
    return client.request()
      .path(TITAN).path(DROP_POINT)
      .GET()
      .bean(Titan.class);
  }
}

@SentryMan SentryMan self-assigned this Oct 18, 2023
@SentryMan SentryMan added the enhancement New feature or request label Oct 18, 2023
@SentryMan SentryMan added this to the 2.0 milestone Oct 18, 2023
@SentryMan SentryMan merged commit 347522b into avaje:master Oct 18, 2023
2 checks passed
@rbygrave
Copy link
Contributor

BTW: I think this is a pretty cool and useful feature. I'd not be surprised to see quite a few folks use it in time.

@SentryMan SentryMan deleted the dynamic-routes branch October 18, 2023 13:08
SentryMan added a commit that referenced this pull request Oct 19, 2023
#323 followup - tidy only and add some extra tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants