About
A URI Template 1) is a compact sequence of characters for describing a range of Uniform Resource Identifiers through variable expansion.
Example
URL template literal
http://example.com/~{username}/
http://example.com/dictionary/{term:1}/{term}
http://example.com/search{?q,lang}
Usage
- to create URI that follows a pattern
- to define and match the accepted URI in a API schema definition such as OpenApi
Library
vertx-uri-template
Java vertx-uri-template
UriTemplate template = UriTemplate.of("http://{host}/product/{id}{?sort}");
String uri = template.expandToString(Variables
.variables()
.set("host", "localhost")
.set("id", "12345")
.set("sort", "price")
);