Jump to content

URI Template

From Wikipedia, the free encyclopedia

This is the current revision of this page, as edited by 2601:18c:cb00:3253:4897:7d3d:2b59:69f (talk) at 18:00, 6 January 2022 (Use an example which (barely) demonstrates the utility of a template over simple string substitution.). The present address (URL) is a permanent link to this version.

(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

A URI Template is a way to specify a URI that includes parameters that must be substituted before the URI is resolved. It was standardized by RFC 6570 in March 2012.

The syntax is usually to enclose the parameter in Braces ({example}). The convention is for a parameter to not be Percent encoded unless it follows a Question Mark (?).

Examples

[edit]
  • http://example.com/people/{firstName}-{lastName}/SSN
  • http://example.com/query{?firstName,lastName}

If we were building these URIs for Björk with firstName=Björk and lastName=Guðmundsdóttir they would be:

  • http://example.com/people/Björk-Guðmundsdóttir/SSN
  • http://example.com/query?firstName=Bj%c3%b6rk&lastName=Gu%c3%b0mundsd%c3%b3ttir

See also

[edit]
[edit]