<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>
<!-- generated by https://github.com/cabo/kramdown-rfc version 1.7.5 (Ruby 2.6.4) -->
<?rfc-ext html-pretty-print="prettyprint https://un5neftqggkzrvwh3w.julianrbryant.com/google/code-prettify/master/loader/run_prettify.js"?>
<rfc xmlns:x="https://umn7fc98gj7rc.julianrbryant.com/net/xml2rfc/ext"
      category="std"
      consensus="true"
      docName="draft-ietf-httpapi-link-template-03"
      ipr="trust200902"
      sortRefs="true"
      symRefs="true"
      tocInclude="true">
   <x:feedback template="mailto:httpapi@ietf.org?subject={docname},%20%22{section}%22\&amp;amp;body=%3c{ref}%3e:"/>
   <front>
      <title abbrev="Link-Template">The Link-Template HTTP Header Field</title>
      <author fullname="Mark Nottingham" initials="M." surname="Nottingham">
         <address>
            <postal>
               <postalLine>Prahran</postalLine>
               <postalLine>Australia</postalLine>
            </postal>
            <email>mnot@mnot.net</email>
            <uri>https://un5gmtkzgj43jehnw4.julianrbryant.com/</uri>
         </address>
      </author>
      <date day="31" month="January" year="2024"/>
      <area>Applications and Real-Time</area>
      <workgroup>Building Blocks for HTTP APIs</workgroup>
      <keyword>link relation</keyword>
      <abstract><?line 44?>
         <t>This 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.</t>
      </abstract>
      <note removeInRFC="true" title="About This Document">
         <t>The latest revision of this draft can be found at <eref target="https://un5m699xrtmzrvvjy3yxmx0eb63f84vwmy64r91w.julianrbryant.com/link-template/draft-ietf-httpapi-link-template.html"/>. Status information for this document may be found at <eref target="https://un5n600td2wm6fx5hkvdpjt61eja2.julianrbryant.com/doc/draft-ietf-httpapi-link-template/"/>.</t>
         <t>Discussion of this document takes place on the Building Blocks for HTTP APIs Working Group mailing list (<eref target="mailto:httpapi@ietf.org"/>), which is archived at <eref target="https://un5ydnvhecfvyenpw3yza9h0br.julianrbryant.com/arch/browse/httpapi/"/>. Subscribe at <eref target="https://un5gmtkzgjpvynwjhkae4.julianrbryant.com/mailman/listinfo/httpapi/"/>.</t>
         <t>Source for this draft and an issue tracker can be found at <eref target="https://github.com/ietf-wg-httpapi/link-template"/>.</t>
      </note>
   </front>
   <middle><?line 49?>
      <section anchor="introduction">
         <name>Introduction</name>
         <t>
            <xref target="URI-TEMPLATE"/> defines a syntax for templates that, when expanded using a set of variables, results in a URI <xref target="URI"/>.</t>
         <t>This specification defines a HTTP header field <xref target="HTTP"/> for conveying templates for links in the headers of a HTTP message. It is complimentary to the Link header field defined in <xref section="3" sectionFormat="of" target="WEB-LINKING"/>, which carries links directly.</t>
         <section anchor="notational-conventions">
            <name>Notational Conventions</name>
            <t>The key words "<bcp14>MUST</bcp14>", "<bcp14>MUST NOT</bcp14>", "<bcp14>REQUIRED</bcp14>", "<bcp14>SHALL</bcp14>", "<bcp14>SHALL NOT</bcp14>", "<bcp14>SHOULD</bcp14>", "<bcp14>SHOULD NOT</bcp14>", "<bcp14>RECOMMENDED</bcp14>", "<bcp14>NOT RECOMMENDED</bcp14>", "<bcp14>MAY</bcp14>", and "<bcp14>OPTIONAL</bcp14>" in this document are to be interpreted as described in BCP 14 <xref target="RFC2119"/>
               <xref target="RFC8174"/> when, and only when, they appear in all capitals, as shown here.</t>
            <?line -18?>
            <t>This specification uses the following terms from <xref target="STRUCTURED-FIELDS"/>: List, String, Display String, Parameter.</t>
         </section>
      </section>
      <section anchor="the-link-template-header-field">
         <name>The Link-Template Header Field</name>
         <t>The Link-Template header field is a Structured Field <xref target="STRUCTURED-FIELDS"/> that serializes one or more links into HTTP message metadata. It is semantically equivalent to the Link header field defined in <xref section="3" sectionFormat="of" target="WEB-LINKING"/>, except that the link target and link anchor can contain URI Templates <xref target="URI-TEMPLATE"/>.</t>
         <t>Its value is a List of Strings. Each String is a URI Template, and Parameters on it carry associated metadata.</t>
         <t>For example:</t>
         <figure>
            <sourcecode type="http-message">
Link-Template: "/{username}"; rel="item"
</sourcecode>
         </figure>
         <t>indicates that a resource with the relation type "item" for a given "username" can be found by expanding the "username" variable into the template given.</t>
         <t>The link target (as defined in <xref section="2" sectionFormat="of" target="WEB-LINKING"/>) is the result of expanding the URI Template <xref target="URI-TEMPLATE"/> (being converted to an absolute URI after expansion, if necessary).</t>
         <t>The link context and link relation type for the link (as defined in <xref section="2" sectionFormat="of" target="WEB-LINKING"/>) are conveyed using the "anchor" and "rel" Parameters, as they are for the Link header field in <xref section="3" sectionFormat="of" target="WEB-LINKING"/>. Their values <bcp14>MUST</bcp14> be Strings.</t>
         <t>However, the "anchor" Parameter <bcp14>MAY</bcp14> contain a URI Template. For example:</t>
         <figure>
            <sourcecode type="http-message">
Link-Template: "/books/{book_id}/author";
               rel="author"; anchor="#{book_id}"
</sourcecode>
         </figure>
         <t>Here, the link to the author for a particular book in a list of books can be found by following the link template.</t>
         <t>This specification defines additional semantics for the "var-base" Parameter on templated links; see below.</t>
         <t>The link's target attributes (as defined in <xref section="2.2" sectionFormat="of" target="WEB-LINKING"/>) are conveyed using other Parameters, in a manner similar to the Link header field. These Parameter values <bcp14>MUST</bcp14> be Strings, unless they contain non-ASCII characters, in which case they <bcp14>MUST</bcp14> be Display Strings. Note that some target attribute names will not serialise as Structure Field Parameter keys (see <xref section="3.1.2" sectionFormat="of" target="STRUCTURED-FIELDS"/>).</t>
         <t>For example:</t>
         <figure>
            <sourcecode type="http-message">
Link-Template: "/author"; rel="author";
               title=%"Bj%c3%b6rn J%c3%a4rnsida"
</sourcecode>
         </figure>
         <t>Implementations <bcp14>MUST</bcp14> support all levels of template defined by <xref target="URI-TEMPLATE"/> in the link String and the anchor Parameter.</t>
         <section anchor="the-var-base-parameter">
            <name>The 'var-base' parameter</name>
            <t>When 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.</t>
            <t>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.</t>
            <t>To determine the URI for a given variable, the value given is used as a base URI in reference resolution (as specified in <xref target="URI"/>). If the resulting URI is still relative, the context of the link is used as the base URI in a further resolution; see <xref target="WEB-LINKING"/>.</t>
            <t>For example:</t>
            <figure>
               <sourcecode type="http-message">
Link-Template: "/widgets/{widget_id}";
               rel="https://un5mkq9urycymemmv4.julianrbryant.com/rel/widget";
               var-base="https://un5mkq9urycymemmv4.julianrbryant.com/vars/"
</sourcecode>
            </figure>
            <t>indicates that a resource with the relation type "https://un5mkq9urycymemmv4.julianrbryant.com/rel/widget" can be found by expanding the "https://un5mkq9urycymemmv4.julianrbryant.com/vars/widget_id" variable into the template given.</t>
            <t>If the current context of the message that the header appears within is "https://un5mkq9urycymemmv4.julianrbryant.com/", the same information could be conveyed by this header field:</t>
            <figure>
               <sourcecode type="http-message">
Link-Template: "/widgets/{widget_id}";
               rel="https://un5mkq9urycymemmv4.julianrbryant.com/rel/widget";
               var-base="/vars/"
</sourcecode>
            </figure>
         </section>
      </section>
      <section anchor="security-considerations">
         <name>Security Considerations</name>
         <t>The security consideration for the Link header field in <xref target="WEB-LINKING"/> and those for URI Templates <xref target="URI-TEMPLATE"/> both apply.</t>
      </section>
      <section anchor="iana-considerations">
         <name>IANA Considerations</name>
         <t>This specification enters the "Link-Template" into the Hypertext Transfer Protocol (HTTP) Field Name Registry.</t>
         <t>
            <list style="symbols">
               <t>Field Name: Link-Template</t>
               <t>Status: permanent</t>
               <t>Specification document: [this document]</t>
            </list>
         </t>
      </section>
   </middle>
   <back>
      <references anchor="sec-normative-references" title="Normative References">
         <reference anchor="HTTP">
            <front>
               <title>HTTP Semantics</title>
               <author fullname="R. Fielding"
                        initials="R."
                        role="editor"
                        surname="Fielding"/>
               <author fullname="M. Nottingham"
                        initials="M."
                        role="editor"
                        surname="Nottingham"/>
               <author fullname="J. Reschke"
                        initials="J."
                        role="editor"
                        surname="Reschke"/>
               <date month="June" year="2022"/>
            </front>
            <seriesInfo name="STD" value="97"/>
            <seriesInfo name="RFC" value="9110"/>
            <seriesInfo name="DOI" value="10.17487/RFC9110"/>
         </reference>
         <reference anchor="URI-TEMPLATE">
            <front>
               <title>URI Template</title>
               <author fullname="J. Gregorio" initials="J." surname="Gregorio"/>
               <author fullname="R. Fielding" initials="R." surname="Fielding"/>
               <author fullname="M. Hadley" initials="M." surname="Hadley"/>
               <author fullname="M. Nottingham" initials="M." surname="Nottingham"/>
               <author fullname="D. Orchard" initials="D." surname="Orchard"/>
               <date month="March" year="2012"/>
            </front>
            <seriesInfo name="RFC" value="6570"/>
            <seriesInfo name="DOI" value="10.17487/RFC6570"/>
         </reference>
         <reference anchor="URI">
            <front>
               <title>Uniform Resource Identifier (URI): Generic Syntax</title>
               <author fullname="T. Berners-Lee" initials="T." surname="Berners-Lee"/>
               <author fullname="R. Fielding" initials="R." surname="Fielding"/>
               <author fullname="L. Masinter" initials="L." surname="Masinter"/>
               <date month="January" year="2005"/>
            </front>
            <seriesInfo name="STD" value="66"/>
            <seriesInfo name="RFC" value="3986"/>
            <seriesInfo name="DOI" value="10.17487/RFC3986"/>
         </reference>
         <reference anchor="WEB-LINKING">
            <front>
               <title>Web Linking</title>
               <author fullname="M. Nottingham" initials="M." surname="Nottingham"/>
               <date month="October" year="2017"/>
            </front>
            <seriesInfo name="RFC" value="8288"/>
            <seriesInfo name="DOI" value="10.17487/RFC8288"/>
         </reference>
         <reference anchor="STRUCTURED-FIELDS">
            <front>
               <title>Structured Field Values for HTTP</title>
               <author fullname="Mark Nottingham" initials="M." surname="Nottingham">
                  <organization>Cloudflare</organization>
               </author>
               <author fullname="Poul-Henning Kamp" initials="P." surname="Kamp">
                  <organization>The Varnish Cache Project</organization>
               </author>
               <date day="23" month="January" year="2024"/>
            </front>
            <seriesInfo name="Internet-Draft" value="draft-ietf-httpbis-sfbis-05"/>
         </reference>
         <reference anchor="RFC2119">
            <front>
               <title>Key words for use in RFCs to Indicate Requirement Levels</title>
               <author fullname="S. Bradner" initials="S." surname="Bradner"/>
               <date month="March" year="1997"/>
            </front>
            <seriesInfo name="BCP" value="14"/>
            <seriesInfo name="RFC" value="2119"/>
            <seriesInfo name="DOI" value="10.17487/RFC2119"/>
         </reference>
         <reference anchor="RFC8174">
            <front>
               <title>Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words</title>
               <author fullname="B. Leiba" initials="B." surname="Leiba"/>
               <date month="May" year="2017"/>
            </front>
            <seriesInfo name="BCP" value="14"/>
            <seriesInfo name="RFC" value="8174"/>
            <seriesInfo name="DOI" value="10.17487/RFC8174"/>
         </reference>
      </references>
   </back>
</rfc>
