<?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.6.34 (Ruby 2.6.4) -->
<?rfc-ext html-pretty-print="prettyprint https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"?>
<rfc xmlns:x="http://purl.org/net/xml2rfc/ext"
      category="std"
      consensus="true"
      docName="draft-ietf-httpapi-link-template-02"
      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://www.mnot.net/</uri>
         </address>
      </author>
      <date day="1" month="February" year="2023"/>
      <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://ietf-wg-httpapi.github.io/link-template/draft-ietf-httpapi-link-template.html"/>. Status information for this document may be found at <eref target="https://datatracker.ietf.org/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://mailarchive.ietf.org/arch/browse/httpapi/"/>. Subscribe at <eref target="https://www.ietf.org/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, 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 it uses URI Templates <xref target="URI-TEMPLATE"/> to convey the structure of links.</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="https://example.org/rel/user"
</sourcecode>
         </figure>
         <t>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.</t>
         <t>The target for the link (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 context, relation type and target attributes for the link are determined as defined for the Link header field in <xref section="3" sectionFormat="of" target="WEB-LINKING"/>.</t>
         <t>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 <bcp14>MUST</bcp14> be Strings.</t>
         <t>Likewise, the requirements for parameters on templated links are the same as those for a Link header field.</t>
         <t>However, the "anchor" parameter <bcp14>MAY</bcp14> contain a URI Template. For example:</t>
         <figure>
            <sourcecode type="http-message">
Link-Template: &lt;/books/{book_id}/author&gt;;
               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>Implementations <bcp14>MUST</bcp14> support all levels of template defined by <xref target="URI-TEMPLATE"/> in both the rel and anchor parameters.</t>
         <t>This specification defines additional semantics for the "var-base" parameter on templated links; see below.</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://example.org/rel/widget";
               var-base="https://example.org/vars/"
</sourcecode>
            </figure>
            <t>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.</t>
            <t>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:</t>
            <figure>
               <sourcecode type="http-message">
Link-Template: "/widgets/{widget_id}";
               rel="https://example.org/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>
         <figure>
            <artwork>
Field Name: Link-Template
Status: permanent
Specification document: [this document]
</artwork>
         </figure>
      </section>
   </middle>
   <back>
      <references title="Normative References">
         <reference anchor="HTTP">
            <front>
               <title>HTTP Semantics</title>
               <author fullname="Roy T. Fielding" initials="R. T." surname="Fielding">
                  <organization>Adobe</organization>
               </author>
               <author fullname="Mark Nottingham" initials="M." surname="Nottingham">
                  <organization>Fastly</organization>
               </author>
               <author fullname="Julian Reschke" initials="J." surname="Reschke">
                  <organization>greenbytes GmbH</organization>
               </author>
               <date day="12" month="September" year="2021"/>
            </front>
            <seriesInfo name="Internet-Draft" value="draft-ietf-httpbis-semantics-19"/>
         </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="M. Nottingham" initials="M." surname="Nottingham"/>
               <author fullname="P-H. Kamp" initials="P-H." surname="Kamp"/>
               <date month="February" year="2021"/>
            </front>
            <seriesInfo name="RFC" value="8941"/>
            <seriesInfo name="DOI" value="10.17487/RFC8941"/>
         </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>
