What is a URI template?

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")
);





Discover More
What is a URI (Uniform resource identifier)?

A Uniform Resource Identifier (URI) is a string of characters that Identify a resource. Because a resource can be created dynamically, an URI is also a request. URL As The ISBN system for...



Share this page:
Follow us:
Task Runner