Add Server Variables for Backends
When creating or editing a backend, you can add server variables to the instance URL on the Servers tab for an in-source server. Server variables are not available for local servers.
When you enter a valid URI template expression, such as {version}
, in an instance URL, a server variable will be created automatically and displayed in the Server editor's Server Variables section. You can also create, edit, or reorder a list of variables. A default value must be set for each server variable.
https://restcountries.com/v3.1/lang/german
as an example:
- The server instance URL can be represented as
https://restcountries.com/{version}/lang
.Here, there's just one server variable,
{version}
, which has a default value of v3.1, as shown in the server of a backend called countryBackend:
Description of the illustration backend-edit-server.png - The endpoint is
/{language}
.We define the service connection on the countryBackend by defining the endpoint and adding
/{language}
to the URL path.
In this example,language
is a path parameter, because it's a part of the endpoint path. It can't be a server variable, in this example, because it's outside the instance URL. Its default value isgerman
and its type is string. - The full URL becomes
https://restcountries.com/{version}/lang/{language}
.After substituting (v3.1 for the server variable
{version}
and german for thelanguage
path parameter), this represents the instance URL we started with,https://restcountries.com/v3.1/lang/german
.