Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
390 views
in Technique[技术] by (71.8m points)

java - Define /mp-rest/url for all clients at once Quarkus YAML

In Quarkus, I am able to define the base url for my clients in my YAML file via the /mp-rest/url property. Currently my YAML file looks like this:

...

"%dev":
  some:
    package:
      name:
        client:
          ExampleService1/mp-rest/url: https://some.url.com
          ExampleService2/mp-rest/url: https://some.url.com

"%tst":
  some:
    package:
      name:
        client:
          ExampleService1/mp-rest/url: https://some.other.url.com
          ExampleService2/mp-rest/url: https://some.other.url.com

...

As you can see I have multiple services which all have the same base url in their respective development environments (all dev base urls are the same, and all tst base urls are the same).

As I have the same base url for each environment's services, I don't want to have to define the url for each service I have.

My Question: Is there a way for me to define the /mp-rest/url for ALL services in my client folder at once? It would have to look something like this (obviously this doesn't work):

"%dev":
  some:
    package:
      name:
        client:
          */mp-rest/url: https://some.url.com
"%tst":
  some:
    package:
      name:
        client:
         */mp-rest/url: https://some.other.url.com

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can define a single configuration that you can use in all your REST Client.

First, define the configuration with a custom name instead of the default package + class name:

country-api/mp-rest/url=https://restcountries.eu/rest

Then tell the REST client to use this custom configuration instead of the default one :

@RegisterRestClient(configKey="country-api")
public interface CountriesService {
    [...]
}

You can find more information here: https://quarkus.io/guides/rest-client#create-the-configuration

EDIT : for application.yml something like this should works

country-api/mp-rest/url: https://restcountries.eu/rest

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...