The Link-Template HTTP Header FieldPrahranAustraliamnot@mnot.nethttps://www.mnot.net/
Applications and Real-Time
Building Blocks for HTTP APIslink relationThis specification defines the Link-Template HTTP header field, providing a means for describing the structure of a link between two resources, so that new links can be generated.The latest revision of this draft can be found at . Status information for this document may be found at .Discussion of this document takes place on the Building Blocks for HTTP APIs Working Group mailing list (), which is archived at . Subscribe at .Source for this draft and an issue tracker can be found at .Introduction defines a syntax for templates that, when expanded using a set of variables, results in a URI .This specification defines a HTTP header field for conveying templates for links in the headers of a HTTP message. It is complimentary to the Link header field defined in , which carries links directly.Notational ConventionsThe key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 when, and only when, they appear in all capitals, as shown here.This specification uses the following terms from : List, String, Parameter.The Link-Template Header FieldThe Link-Template header field is a Structured Field that serializes one or more links into HTTP message metadata. It is semantically equivalent to the Link header field defined in , except that it uses URI Templates to convey the structure of links.Its value is a List of Strings. Each String is a URI Template, and Parameters on it carry associated metadata.For example:indicates that a resource with the relation type "https://example.org/rel/user" can be found by expanding the "username" variable into the template given.The target for the link (as defined in ) is the result of expanding the URI Template (being converted to an absolute URI after expansion, if necessary).The context, relation type and target attributes for the link are determined as defined for the Link header field in .Parameters on a templated link have identical semantics to those of a Link header field. This includes (but is not limited to) the use of the "rel" parameter to convey the relation type, the "anchor" parameter to modify the context IRI, and so on. Parameter values MUST be Strings.Likewise, the requirements for parameters on templated links are the same as those for a Link header field.However, the "anchor" parameter MAY contain a URI Template. For example:Here, the link to the author for a particular book in a list of books can be found by following the link template.Implementations MUST support all levels of template defined by in both the rel and anchor parameters.This specification defines additional semantics for the "var-base" parameter on templated links; see below.The 'var-base' parameterWhen a templated link has a 'var-base' parameter, its value conveys a URI-reference that is used as a base URI for the variable names in the URI template. This allows template variables to be globally identified, rather than specific to the context of use.Dereferencing the URI for a particular variable might lead to more information about the syntax or semantics of that variable; specification of particular formats for this information is out of scope for this document.To determine the URI for a given variable, the value given is used as a base URI in reference resolution (as specified in ). If the resulting URI is still relative, the context of the link is used as the base URI in a further resolution; see .For example:indicates that a resource with the relation type "https://example.org/rel/widget" can be found by expanding the "https://example.org/vars/widget_id" variable into the template given.If the current context of the message that the header appears within is "https://example.org/", the same information could be conveyed by this header field:Security ConsiderationsThe security consideration for the Link header field in and those for URI Templates both apply.IANA ConsiderationsThis specification enters the "Link-Template" into the Hypertext Transfer Protocol (HTTP) Field Name Registry.HTTP SemanticsAdobeFastlygreenbytes GmbHURI TemplateUniform Resource Identifier (URI): Generic SyntaxWeb LinkingStructured Field Values for HTTPKey words for use in RFCs to Indicate Requirement LevelsAmbiguity of Uppercase vs Lowercase in RFC 2119 Key Words